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