The ajax loading Page Server Returns 304 not modified

Source: Internet
Author: User

Since all your servers return 304 not modified

It indicates that on the server, your xml file has not been modified, or the page to be loaded has not been modified locally. The local cache causes this problem.

A common method to prevent caching is to add a random number to the backend, or you can add a timestamp.

For example

Url = "... xml? T = "+ (new Date (). getTime (). toString ();

In this example, I use the following methods:
Copy codeThe Code is as follows:
Var destination = "test.html"

Function goto (destination ){
Var ajaxobj = new AJAXRequest; // create an AJAX object. The class is in the file.
Ajaxobj. method = "GET"; // set the request method to GET
Ajaxobj. url = destination + "? T = "+ (new Date ()). getTime (). toString (); // The response URL, which can be changed to some dynamic processing pages later. It will be known by Ajax, which can return different data for the purpose of the page.
// Set the callback function and output the response content. Because it is a static page (which is my requirement), all the content has come.
Ajaxobj. callback = function (xmlobj ){
Document. getElementById ('page _ content'). innerHTML = xmlobj. responseText; // you can check this sentence.
}
Ajaxobj. send (); // send the request
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.