Reputation: 5651
In this tutorial teaching how to place markers in the map: https://developers.google.com/maps/articles/phpsqlajax_v3 there is a doNothing() function which is used in:
request.onreadystatechange = doNothing;
What is the point of this function/line? Is it just to demonstrate that you can add any functions you want?
Upvotes: 0
Views: 104
Reputation: 117334
There are some bugs where it may happen that a readystatechange-event with readystate 4 fires multiple times(see e.g. http://code.google.com/p/chromium/issues/detail?id=159827)
Assigning the empty function prevents the original callback from getting executed multiple times in the browsers affected by this bug.
Upvotes: 2
Reputation: 28860
There is no purpose for it. It's a dummy example function. (Ha! So I thought. See Dr. Molle's anwer for a correction.)
But are you using jQuery? If you are, you don't need that downloadUrl()
function anyway. You can use jQuery's $.get()
or $.ajax()
function instead. Where you see code like this:
downloadUrl( "phpsqlajax_genxml.php", function(data) {
var xml = data.responseXML;
// do stuff with xml
});
You can change it to:
$.get( "phpsqlajax_genxml.php", function(xml) {
// do stuff with xml
}, "xml" );
As a side note, it's really unfortunate that that Google Maps XML tutorial has never been updated to use JSON instead of XML. If you're generating the XML from your server, it's just as easy to generate JSON instead, and it's much easier to work with JSON instead of XML in the JavaScript code.
Upvotes: 0