Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#7749 closed bug (worksforme)

.ajaxError() isn't called when the page is in an iframe of another page

Reported by: [email protected] Owned by: [email protected]
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:


I have a page (parent.html) with an iframe pointing to child.html. In child.html I have ajax calls that might return with error 500.

.ajaxError() gets called when I open child.html on itself but not when it's part of parent.html as an iframe.

Change History (5)

comment:1 Changed 12 years ago by addyosmani

Owner: set to [email protected]
Status: newpending

Thank you for submitting a ticket to the jQuery Bug Tracker!

In order for us to evaluate the bug you are experiencing, we'll need you to submit a reduced test case on http://jsfiddle.net that reproduces the behaviour you are experiencing so that we can further establish whether this is indeed a bug.

comment:2 Changed 12 years ago by dmethvin

Resolution: worksforme
Status: pendingclosed

The behavior described by the reporter is correct. jQuery does not attempt to throw the ajaxError back to the parent frame, this is not even possible when the parent is another domain.

comment:3 Changed 12 years ago by anonymous


Many thanks for the quick response. I'm not trying to throw the ajaxError back to the parent frame nor doing any communication between parent and child frame. What I'm seeing is different behavior on $.ajax error callback when the page is in an iframe or standalone.

Suppose I have this ajax call in child.html:

   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
     //Works fine on both standalone and within an iframe
     alert("Data Saved: " + msg);
   error: function() {
     //only works when it's standalone
     alert("error callback is called");

If I open child.html by itself and the ajax request fails, the alert on error callback is called. But if I open parent.html and ajax request on child.html fails, the error callback won't get called at all (no alert). Success callback works just fine on both modes.

Is that the correct behavior for $.ajax?

comment:5 Changed 12 years ago by [email protected]

I can confirm that jitter is right, error callback on $.ajax behave the same way on both modes (in iframe and standalone). It's a firebug issue where console.error("") is skipped when child.html is viewed in iframe.

Note: See TracTickets for help on using tickets.