Ticket #7749 (closed bug: worksforme)
.ajaxError() isn't called when the page is in an iframe of another page
| Reported by: | squidcombo@… | Owned by: | squidcombo@… |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.6 |
| Component: | unfiled | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
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
comment:1 Changed 3 years ago by addyosmani
- Owner set to squidcombo@…
- Status changed from new to pending
comment:2 Changed 2 years ago by dmethvin
- Status changed from pending to closed
- Resolution set to worksforme
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 2 years ago by anonymous
dmethvin,
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:
$.ajax({
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?
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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.