earth tech

[software and hardware technology originating from or otherwise pertinent to planet earth]

use these buttons to share this blog on portal sites:

Add to Google

Sunday, November 8, 2009

 

AJAX Offline: referencing the window.location

http://www.javascriptkit.com/jsref/ajax.shtml

The javascriptkit.com site makes some interesting points about AJAX and the implementation of the responseXML property of the XMLHttpRequest object.

"If you're running an Ajax request offline locally on your PC, a value of 0 is returned by status in most browsers regardless of the actual request status, even if it was successful. To run and test Ajax requests locally, it should overlook the status code being 200, and merely rely on a readyState value of 4. The following example takes into account the request possibly being run offline and to enable it:"

var myrequest = new ajaxRequest()
myrequest.onreadystatechange=function() {
  if ( myrequest.readyState == 4 ) { //if request has completed
    if ( myrequest.status == 200 || 
      window.location.href.indexOf("http") == -1 ) {

      /* if request was successful 
         (versus "page not found" etc) 
         or if run offline (rely on readyState of
         4 alone then) */

      // ... do something with returned data ...

  }
 }
}

From the example, it is clear that the test

window.location.href.indexOf("http") == -1

can be generally useful for other things - like finding the protocol string from the URL of the current document. In theory, at least, this should tell you what protocol was used to load the content of window.

Labels: , , ,

Thursday, October 29, 2009

 

WtF AJAX

http://www.thomasfrank.se/easier_than_ajax.html

This has got to be the sickist piece of Javascript ever, in the bitniverse. A True Manifestation of The Overmind. Or is that Infestation? Must use this code. http://www.thomasfrank.se/easier_than_ajax.html

Labels: ,

 

AJAX Javascript Includes as RPC

http://www.phpied.com/javascript-include/

A really great blog post about how to do javascript includes using "asynchronous javascript" XMLHTTP requests to server-side PHP scripts.

The article shows how to do 'include_once' and 'on-demand' loading of javascript code, which can be executed by the browser to modify the current document, including by use of HTTP GET request results assigned to the DOM.

Labels: , , , ,

Wednesday, October 28, 2009

 

AJAX PHP Javascript MySQL XML

Wacka-wacka DOOOO!

Today's brain teaser is AJAX + PHP + Javascript + XML + MySQL ... and there may be some others I've left out CSS, XHTML, stuff like that.

Nevertheless, we will prevail. Links to follow.^

Nothing specific to the MySQL side of this, for now.

Labels: , , , , ,

Archives

2006/12   2007/01   2007/05   2007/06   2007/07   2007/08   2007/10   2008/01   2008/02   2008/03   2008/05   2008/11   2008/12   2009/01   2009/02   2009/03   2009/04   2009/05   2009/07   2009/09   2009/10   2009/11   2009/12   2010/01  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]