Jquery .Get() pulls NULL in Internet Explorer

I have a problem with an AJAX call in JQuery. It works on Chrome, FF, and Safari, but not IE. In fact in IE nothing happens at all, no errors, no data loaded.

Here is the code:

    $(document).ready(function() {

     $.ajaxSetup({ cache: false });

        $.get("ShoppingCart2.aspx", { }, function(data) {
           //query the jq object for the values

        alert(data);       
        alert($(data).find('#Items').text());


        var intI = parseInt(($(data).find('#Items').html()));

With the alert data I find all the data from the page I am making a call from, but unfortunately my data.find methods pull up null for IE. I'm not sure if it's the code or the browser, but I am really stuck. Thank you for the help.

Edit: I did add in the cache: false command, but still I have no luck. I really cannot understand why this won't work in IE.

Answers


Try this (once in your page/external js, before your AJAX calls):

$.ajaxSetup({ cache: false });

IE likes to cache the hell out of things, and if you were testing and had no content there at one point, chances are IE is holding onto it. Using $.ajaxSetup() and and telling it by default to not cache AJAX results should resolve this. If you're curious, it's sticking a timestamp on the URL as a cache breaker under the covers, use fiddler to see this happening.


Is it perhaps caching the AJAX? What happens if you put this before your code:

$.ajaxSetup({ cache:false });

A quick solution without coding it could be to press CTR+F5 to clear the cache upon refresh.


Well I was unable to make the .find part of the .get work in internet explorer, but I did find a way to get the ajax information I needed:

var information = $.ajax({ type: "GET", dataType: "html", url: "ShoppingCart2.aspx", data: querystring, async: false }).responseText + " ";

This passes a query string to the website then gets information from the website back into one big string. I then manipulated that string to get what I needed. Unfortunately it is a lot slower than the .get command, but it is a fix.

Thanks for the help everyone!


Need Your Help

Can any one help me to display current time zone in a label?

objective-c xcode

Can any one help me to display current time zone in a label in xcode(objective-c)?