views:

137

answers:

2

Hi,

Could anyone please help me with this? I have a web page using .manifest for offline storage caching. In that page, I use jQuery ajax call to get the data from the server. If I first load the page, it is OK. I can switch between Online and Offline. But the problem is when I go back online and refresh the page. jQuery ajax cannot be able to talk to server anymore. Is there a way to for ajax to talk to the server or clear offline cache?

My ajax call is as such:

        $.ajax({

            type: "GET",

            url: requestUrl,
            success: localSuccess,

            error: error,

            dataType: "text",
            cache:false
        });
+1  A: 

I have this piece of code at the top of each page/Master page

    //Disable caching in IE, becuase it's EVIL!
    $(document).ready(function () {
        $.ajaxSetup({ cache: false });
    });
Alastair Pitts
I just wrote that but held off posting because 'cache:false' is already being passed as the last setting in the example given.
istruble
Thanks, Alastair. But I still cannot connect to the server. :(. I am now wondering if it is to do with browser cache.
cynwong
@cynwong: Oops, didn't see the `cache:false` in the ajax call. Then my code won't help. Can you provide more details/more javascript in regards to the deciding between online/offline. I'm a little confused.
Alastair Pitts
Alastair, I am detecting online/offline with navigator.onLine. I am using HTML5 localStorage feature. I would like to sync when it is online. So when offline, users will still be able to access the data and modify it if they want.
cynwong
A: 

put the random string into url like "get.php?random="+Math.random()" can solve this problem. It is not the best solution but It works great.

DominixZ