Solved

data not refreshed

Posted on 2013-05-13
3
316 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 82

Accepted Solution

by:
leakim971 earned 500 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 82

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

777 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