Skip to main content

Bug Tracker

Side navigation

#5059 closed bug (invalid)

Opened August 16, 2009 09:29PM UTC

Closed November 19, 2010 01:07AM UTC

Last modified March 15, 2012 11:28AM UTC

No error handling for cross site ajax

Reported by: ooktay Owned by:
Priority: major Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:

For cross site ajax, when remote site is down error handlers are not called.

Here is my mod for error handling:

-------------------START line:3473 in v1.3.2

If we're requesting a remote document

and trying to load JSON or Script with a GET

if ( s.dataType == "script" && type == "GET" && parts

&& ( parts[1] && parts[1] != location.protocol || parts[2] != )){

var head = document.getElementsByTagName("head")[0];

var script = document.createElement("script");

script.src = s.url;

if (s.scriptCharset)

script.charset = s.scriptCharset;

Error handling on firefox (DOM standard)

script.onerror = function(){

jQuery.handleError(s, null, "error");



Handle Script loading

if ( !jsonp ) {

var done = false;

Attach handlers for all browsers

script.onload = script.onreadystatechange = function(){

if ( !done && ( !this.readyState ||

this.readyState == "loaded" || this.readyState == "complete") ) {

done = true;

Note that IE will call success even when connection is down

We can't do anything about it since IE doesn't have a way to tell



Handle memory leak in IE

script.onload = script.onreadystatechange = null;

head.removeChild( script );



} else {

script.onreadystatechange = function(){

Error handling for IE:

if connection is down, handler is not run, hence window[ jsonp ] is still there

if ( !done && (this.readyState == "loaded" || this.readyState == "complete")

&& window[ jsonp ] ) {

done = true;

Handle memory leak in IE

script.onreadystatechange = null;

window[ jsonp ] = undefined;

try{ delete window[ jsonp ]; } catch(e){}

if ( head )

head.removeChild( script );

jQuery.handleError(s, null, "error");





Use insertBefore instead of appendChild to circumvent an IE6 bug.

This arises when a base node is used (#2709 and #4378).

head.insertBefore( script, head.firstChild );

We handle everything using the script element injection

return undefined;



Attachments (1)
  • ajax.txt (15.5 KB) - added by ooktay August 18, 2009 07:05PM UTC.
Change History (4)

Changed August 16, 2009 09:41PM UTC by ooktay comment:1

For cross site ajax, when remote site is down error handlers are not called.

I have attached my mod ajax.txt for error handling. Search for "ooktay:"



Changed August 18, 2009 12:49AM UTC by dmethvin comment:2

If your proposed solution doesn't handle errors consistently in IE, that seems like a serious drawback.

Changed August 18, 2009 07:21PM UTC by ooktay comment:3

You're right. I guess having just FF handle errors is out of question :)

I'll check what we can do about IE.

Changed November 19, 2010 01:07AM UTC by dmethvin comment:4

resolution: → invalid
status: newclosed