Skip to main content

Bug Tracker

Side navigation

#7749 closed bug (worksforme)

Opened December 10, 2010 10:57PM UTC

Closed December 23, 2010 06:33PM UTC

Last modified January 19, 2011 06:26PM UTC

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

Reported by: squidcombo@hotmail.com Owned by: squidcombo@hotmail.com
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.

Attachments (0)
Change History (5)

Changed December 11, 2010 10:53AM UTC by addyosmani comment:1

owner: → squidcombo@hotmail.com
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.

Changed December 23, 2010 06:33PM UTC by dmethvin comment:2

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.

Changed January 18, 2011 09:34PM UTC by anonymous comment:3

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?

Changed January 19, 2011 01:46AM UTC by jitter comment:4

Changed January 19, 2011 06:26PM UTC by squidcombo@hotmail.com comment:5

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.