jquery's getJson method reads the same request directly from the cache after the first request to the server to get the returned data, and no longer requests the database.
Here's how to fix it:
1 Make the URL different for each call Method: Add a random number to the parameter. Example 1: jQuery.getJSON("$!{ Root}/a/a/s.ashx",{"ID":id,"Name":name,"Path":path,random:Math.random()},function(responseText){} Example 2: "xxx.aspx?randID="+Math.random Example 3: "xxx.aspx?randID="+ escape(new Date()) 2 Set cache to False $.ajax uncached version: $.ajax({
type:"GET"
url:'test.html',
cache:false,
dataType:"html",
success:function(msg){ alert(msg);
} }); 3. Include the following statement at the top of the labels.html file:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1"> 4. The load function can not only call HTML, but also script, such as labels.php, you can use the header function in the php file:
<?php
header("Cache-Control: no-cache, must-revalidate");
?> 5 Use post instead of get method. When using the Post method, you need to pay attention to: Set the header's Context-Type to application/x-www-form-urlencode to ensure that the server knows that there are parameter variables in the entity. Usually use the SetRequestHeader("Context-Type","application/x-www- form-urlencoded) of the XmlHttpRequest object; ")。 Example:
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); The parameter is a key-value pair corresponding to the name/value, and each pair of values is separated by an > sign. For example, var name=abc&sex=man&age=18, pay attention to var name=update.php?
abc&sex=man&age=18 and var name=?abc&sex=man&age=18 are written incorrectly; The argument is sent in the Send method, e.g. xmlHttp.send(name); If it is a get method, directly xmlHttp.send(null);
The server-side request parameter distinguishes between Get and Post. If it is the get method, then $username = $_GET["username"]; If it is a post method, then $username = $_POST["username"]; 6 Add header("Cache-Control: no-cache, must-reva lidate") on the server side; 7 Add xmlHttpRequest.setRequestHeader("If-Modified-Since","0") before ajax sends the request; 8 Add xmlHttpRequest.setRequestHeader("Cache-Control","no-cache") before ajax sends the request;
|