error callback
xhrGet calling error instead of load on IE6 when no error occurs
Posted May 6th, 2008 by calastI am converting some clunky old pages to use dojo 1.1, and ran into a snag when doing cross browser testing. Everything is fine in Firefox, but fails in IE 6. The basic approach here is to invoke a php file on the server in response to user click, and have it return a JSON structure based on what it finds in the database. That JSON structure is then used to build a table in a div by DOM manipulation. Looks good, runs fast – but not in IE.
The interesting problem in IE is that the error function is called instead of the load function. If I examine the HTTP response, it is 200 and the response string is “OK” – as you would expect if no error occurred. But how then did that function get invoked, if there was no error? Why not the proper load function? The JSON looks correct, and seems properly interpreted in Firefox.
Here’s what it looks like:
dojo.xhrGet({
url: 'searchResultsJSON.php?' + paramString,
handleAs: "json",
load: function(response, ioArgs) {
if ( response.matches.length == 0 )
alert("No matching records found.");
else {
// do a bunch of DOM manipulation here
}
}
return response;
},
error: function(response, ioArgs) {
alert('Error when retrieving search results from the server: ' + ioArgs.url);
}
});
The JSON stuff is just raw JSON.
{ “matches”: [array full of stuff ] }
Does IE require something else, like headers, perhaps? I’m at a bit of a loss here in how to make this work in other browsers, so I’d appreciate any guidance as to why this isn’t sufficiently portable.
Dojo Forum