Solved

disable caching while using ajax script

Posted on 2010-09-08
2
368 Views
Last Modified: 2012-05-10
I am running an ajax script that calls a php script that runs a query and returns the values to a specific div.

The problem I am running into is that when I refresh the page the webpage wants to use the cashe because it will load faster, I want it to run the ajax script so it will run the query and show me the updated information...

I guess I need to disable to cashe...Thats what I am not sure how to do..
0
Comment
Question by:brad0525
2 Comments
 
LVL 5

Accepted Solution

by:
sscotti earned 500 total points
ID: 33628293
Not a pro at that, but as far as the php script is concerned you can usually use headers to force no cache:

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

See http://php.net/manual/en/function.header.php.

You can also see:

http://www.sitepoint.com/forums/showthread.php?t=335651
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33628419
make a new url everytime
var myTime = myDate.getTime();
var url=’http://localhost/call_to_ajax.php?rand=’+myTime;
http.open(‘GET’, url);

this will make sure that request goes to server every time
check this also
http://hungred.com/how-to/tutorial-stop-caching-jquery-javascript/
http://starcoder.wordpress.com/2006/12/05/deep-tech-fusion/
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I upload multiple images from a HTML form? 2 27
How to Left-Align Navigation bar? 4 26
HTML5 frame 5 25
Create tabs to show divs 9 27
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
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…

785 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