Skip to main content

Bug Tracker

Side navigation

#2816 closed bug (fixed)

Opened May 07, 2008 10:04AM UTC

Closed May 13, 2008 07:47PM UTC

erroneous behavior with IE when re-ajaxifying links in an ajax-loaded div

Reported by: lamyseba Owned by:
Priority: major Milestone: 1.2.4
Component: ajax Version: 1.2.3
Keywords: ajax, IE, absolute url, second time replace Cc:
Blocked by: Blocking:

I used the Jquery ajax content plugin (

), wich itself use the ajax behaviour of jquery.

I use ajax to replace a whole div. As there are some ajax links inside the div, I re-ajaxify them after the div is replaced, using ajaxContent.

This works fine with Firefox, Safari, Konqueror, but in IE 6-7 I got a strange behaviour: the first "ajaxification" of the link works well,but the re-ajaxification does not work well.

Investigating, I realized that IE interprets all the urls coming back from an ajax call, and includes the host into them.

i.e : "/my/relative/url.html"

will become: "".

This cause jQuery to interpret the second ajax call differently. In

jQuery-1.2.3.js, at line 2631, there is a test:

// If we're requesting a remote document and trying to load JSON //or Script with a GET
if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && s.dataType == "script" && s.type.toLowerCase() == "get" ) {

This test will not be passed the first time, and it will be passed the second Time in IE only, causing this strange behaviour.

  • The solution I adopted is to always remove the host before doing the call.
  • A better solution would be to modify jquery so that it checks wether the host is the same as the one in the url we're coming from, rather than just check if url contains (http) or (//). This will make IE behave the same in the first and second ajax call

Anyway, what caused the strange behaviour was the fact that the "X-

Requested-With" header wasn't set if the test was passed. And I needed this header for my application to work correctly (I'm using Ruby on Rails). So, maybe a good idea would be to add this header in all case, may this test be passed or not.



Attachments (1)
  • remote-ajax.diff (0.7 KB) - added by flesler May 13, 2008 03:19AM UTC.

    This should fix the former naive check ( shouldn't '//' be '/' ? )

Change History (2)

Changed May 13, 2008 06:20AM UTC by davidserduke comment:1

The reason that check is in there is for #1750 but perhaps there is another check needed too?

Changed May 13, 2008 07:47PM UTC by flesler comment:2

resolution: → fixed
status: newclosed

Closed at [5586].