Under the IE browser, the ajax request is sent successfully for the first time, and the second time shows that the call to the background interface comes from the cache.

As shown in the picture, because of the use of the layui framework, I thought it was the impact of the table.on() event, which caused the request to be placed on the IE browser. The first request can be called to the background interface, and the data can also be saved, but the second send It is not successful, indicating that the calling interface comes from the cache. After deleting the cache, it can be sent again successfully.

After checking the information, I found out the caching principle of ajax. After the data sent by Ajax is successful, it will save the requested URL and the returned response result in the cache. When calling Ajax to send the same request next time, it will be directly from the cache. Take out the data, this is to improve the response speed and user experience of the page. Currently this requires that the URL be requested exactly the same twice, including parameters. At this time, the browser will not interact with the server.

 

So for this problem, you only need to add a random number or a timestamp after the url, then every time you request, it will be a different url and the call will be successful.

 

solution:

1. Add "?num=" + Math.random() after the Ajax URL parameter; 

2. Similar to the above, add "?timestamp=" + new Date().getTime() after the URL parameter

Guess you like

Origin blog.csdn.net/PhilipJ0303/article/details/100558569