Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#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:
Blocked by: Blocking:

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 (5)

comment:1 Changed 8 years ago by addyosmani

Owner: set to squidcombo@…
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 8 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 8 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?

comment:5 Changed 8 years ago by squidcombo@…

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.