The cache data of the AJAX request server is not refreshed in time.

Source: Internet
Author: User

Recently, when I was working on a project, I used ajax to request server data! At the beginning, I can test that everything works normally (I'm not a professional tester! So we still haven't figured out some problems )! Later, the data in the ajax request has changed, but the page data has not changed. It is still the first data! This problem has caused me a lot of trouble! [The technology is not in place.] There is no way to solve the problem! It's just a slap in the head! Because ajax requests are also executed on the background page, click the breakpoint! Hey, I found a problem through the breakpoint! Every time ajax requests him to go to the backend for the first time, he will not go to the backend! If your other buttons change the data, because ajax will not execute data in the background after the second time! Therefore, the data is not refreshed in time [the data is cached. If you restart IE, you can see the modified data]. A little hope! At least the symptoms are found! Next, how can we solve this problem! Hey, come back and remind Bobby's colleagues to add a timestamp parameter to the ajax request url for a try! That's the case! I don't have a good solution anyway! Haha! [Thanks bobby] (or your technology is not in place! Khan ...) Later I went to google, and many people encountered this problem! The following describes your understanding and network resources to solve this problem! [In IE, if the URL submitted by XMLHttpRequest is the same as that in history, the cache is used and it is not submitted to the server. Therefore, you cannot obtain the data you just submitted.]

My initial practice: After the following code is run! Click the GetData button for the first time to display the demo. After you click changDate to change the data, click GetData to display the demo! Instead of the expected changed data string! This is my first problem! Of course, the following is a simple demo, which does not have much practical significance!

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "ajax_Default" %> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

 

The above two methods have passed the test! And solved my problem!

Technorati Tag: ajax
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.