Solved

data not refreshed

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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)

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now