Download jQuery not updating document in Internet Explorer

Scary IE strikes again. :(

Over the past few days, I have been developing a tool for selecting and loading images for Tiny MCE using modal dialogs. During the script, the jQuery load () function is used several times to load external HTML and insert it into the specified div element.

Everything went fine, even in IE, until about half an hour ago, when I loaded IE to check the change, and all calls to load () now do nothing. If the content should appear in the document (by checking the developer tools), there is an empty div. No error reported either. However, I can update the item manually using html ().

Until a few hours ago everything was working fine in IE ... now it does nothing. I tried using the full addresses (no such luck), cleared the browser cache and tried to send headers without a cache from the php document called by the load () function. Could this be some kind of caching issue?

Here is an example of the first of many such calls:

//Create the dialog. if ($('#imgPropDialog').length == 0) { $('body').append('<div id="imgPropDialog" class="jqmWindow"></div>'); $('#imgPropDialog').load('system/admin/ajax/image_properties.php'); } 

div imgPropDialog is correctly added and displayed inside the document in IE. But the content of image_properties.php never appears. Works great in Chrome (and, presumably, in any other browser than in IE).

Any ideas before I start ripping off all my changes? Thanks

+4
source share
4 answers

You can quickly check if your caching is your problem by adding a random query string to this URL:

 $('#imgPropDialog').load('system/admin/ajax/image_properties.php?_=1234'); 

If this makes it work, then your caching is your problem. AJAX GET requests (which uses .load ()) are cached by IE. If you want to stop caching on demand, you will need to use $ .ajax () instead, the cache parameter is set to false. Alternatively, you can create your own random query string (which still has the jQuery cache: false parameter).

Or, if you want to completely disable AJAX caching, do the following:

 $.ajaxSetup ({ // Disable caching of AJAX responses */ cache: false }); 

See this question: Stop jQuery.load from caching

EDIT

Extra suggestion: try something like this and see what happens

 $.ajax({url: 'system/admin/ajax/image_properties.php', cache: false, success: function(data, textStatus) { alert($(data).html()); }}); 

We hope this warning tells you that (if any) information is being returned. If it doesn't pop up, either the request somehow crashes, or IE somehow ignores the no-cache.

+7
source

A quick workaround, add a random number as a parameter to make sure that every time there is a new request .

eg.

$ ('# divID'). load (jspFrom + '? param1name =' + param1value + 'param2name =' + param2value + '& random =' + Math.random () ;

+1
source

I had a similar problem loading content in a div in IE (although I did not use load() , just get() ). Verify that the contents of the page you are loading are syntactically correct. IE sometimes will not display content at all if the content has something wrong. In my case, the entire content block that I was trying to load did not display due to the CSS max-height attribute for the element I used. IE can be very lazy without worrying about fixing the content at all.

0
source

It seems that the problem was actually a problem with my user authentication in image_properties.php file. For my user authentication, I create a fingerprint of various headers to add a little extra security. One of them was HTTP_ACCEPT_LANGUAGE - for some reason, this particular header was changed for AJAX requests in Internet Explorer (but not for regular page loads) and, therefore, to refuse user authentication.

However, Ender's advice helped me. :)
0
source

All Articles