Solved

disable caching while using ajax script

Posted on 2010-09-08
2
365 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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…

762 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

22 Experts available now in Live!

Get 1:1 Help Now