Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

data not refreshed

Posted on 2013-05-13
3
Medium Priority
?
326 Views
Last Modified: 2013-05-14
I have a page that, on $(document).ready calls on ASP page to "draw" a previously completed survey (checkboxes and textboxes). The user can then make changes and return back to a 'summary' page by:  window.location.href

When they click in the summary to go back to the detail, the data that shows is what was originally entered, not the latest data.  It is not until I completely close the browser, re-open the summary, and click to the detail that I see the saved changes.  It is as if the first one is saved in cache???

When clicking on the link on the summary page, I tried adding a random number to the url  but that didn't seem to fix it:  http://forum.jquery.com/topic/force-page-update
0
Comment
Question by:KCTechNet
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39163572
I have a page that, on $(document).ready calls on ASP page to "draw" a previously

If that mean you're using ajax, set cache:false
check it in the settings list here : http://api.jquery.com/jQuery.ajax/
0
 

Author Comment

by:KCTechNet
ID: 39165016
After reading more about cache, I realized that it was the data load that pulling from cache, the the survey page itself.

So, I incorporated your suggestion and moved the random number to the getJSON url.  I guess overkill but I had seen a post from someone where they said the cache would stop working after a few page loads and I can't have that happening:

        var randomnumber=Math.floor(Math.random()*100000);
        $.ajaxSetup({ cache: false });
        $.getJSON( 'DynamicReturn.asp?rn='+ randomnumber,    {proc:"GetPMSurveyResponses",params: varParams}, function (data) { 

Open in new window


Thank you for your time.
0
 
LVL 83

Expert Comment

by:leakim971
ID: 39165144
moved the random number to the getJSON url

this is what cache:false do

Math.floor(Math.random()*100000);
if you're very unlucky you can get two times the same number
I prefer :
new Date().getTime()
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question