Ticket #1145 (closed bug: fixed)
error callback does not get called for many errors
| Reported by: | jakecigar | Owned by: | john |
|---|---|---|---|
| Priority: | major | Milestone: | 1.1.4 |
| Component: | ajax | Version: | 1.1.3 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description (last modified by john) (diff)
I assumed (incorrectly) that the error callback would be called for malformed xml. it is not. I've had to code around this with the complete callback.
I can now catch safari(webkit), firefox 2 & opera 9, I have no idea what IE will do.
var surveyComplete = function(xrh, status){
var xml = xrh.responseXML if (status!="success")
form.html("<h1>" + status.toUpperCase() + " requesting:<a href='" + url + "'>" + url +"</a></h1>")
.append("<pre>" + xrh.responseText + "</pre>")
else if (!xml) safari webkit
form.text(xrh.responseText).wrap("<pre></pre>")
.prepend("<h1> broken xml:<a href='" + url + "'>" + url +"</a> </h1>")
else if (xml.hasChildNodes && !xml.hasChildNodes()) opera
form.text(xrh.responseText).wrap("<pre></pre>")
.prepend("<h1> broken xml:<a href='" + url + "'>" + url +"</a> </h1>")
else if (xml.firstChild.nodeName == "parsererror") firefox
form.text(xrh.responseText).wrap("<pre></pre>")
.prepend("<h1> broken xml:<a href='" + url + "'>" + url +"</a> </h1>"+ $.xml(xml))
else
surveyProcess(xml)
} $.ajax({url:url,datatype:'xml',complete:surveyComplete})
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I use similar logic in the Taconite plugin when converting a string to a document: