1

I have an ASP.Net application that uses jQuery's AJAX POST method to update the DOM.

  1. user enters a date
  2. user clicks a link button
  3. JQuery ajax post call to a database loads a div with requested data.

Everything works fine, unless the user manually refreshes the page in IE.
If they make a change then hit the browser refresh button, then follow those three steps again, it doesn't show the updated data that they just entered even though the database has been properly updated.

It shows the original data.

They have to close the browser altogether and re-open it to see the changes.

This only happens in IE.
FF and Chrome show the changes if they refresh.

What am I missing here?

1
  • 1
    Your code is missing here. Wihtout that how can we help you ? Commented Aug 14, 2012 at 10:47

2 Answers 2

5

Internet Explorer caches AJAX requests to URLs, and will simply return the cached response when you make another AJAX call to that same URL. Thankfully, setting the cache option on a jQuery AJAX call to false will result in a timestamp being appended to the URL, bypassing the caching.

To set that option for ALL jQuery AJAX requests you can use the $.ajaxSetup() function like so:

$.ajaxSetup({cache : false});

Put that at the top of your .js file so that it's executed prior to any AJAX requests.

Sign up to request clarification or add additional context in comments.

Comments

0

I don't understand what actually you want, but you cad something like this:

  1. create hidden input which it's value indicate if the page is loaded for first time or this is post back.
  2. From code behind when inside Page_loaded() event check if the page is loaded for first time or not and store a bool value in the hidden input in indicate that.
  3. Inside $(document).ready() function check for that hidden input value and based on that you can decide either to make your Jquery ajax call or not.

1 Comment

OP said that issues only occurs in IE but code is working fine in FF and Chrome. Suggesting different implementation details possibly requiring code changes server and client-side may be a little premature at this stage. It might be better to look at why it is not working in IE first. Off course, any script/html OP could post would help in that matter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.