当前位置:网站首页>Prevent the processing of post requests in AJAX in page URL cache
Prevent the processing of post requests in AJAX in page URL cache
2022-07-20 17:27:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
Generally, we often use it in development Ajax request , Send requests asynchronously , Then get the data we want , stay Ajax Use in Get There is no page caching problem when requesting data , While using POST Sometimes the page will cache the information we submitted , As a result, the asynchronous request we send cannot correctly return the data we want , So in this case , What should we do ???
Here is a way to prevent ajax in post request Page caching url Information :
$.post(url,data ,ranNum:Math.random()} ,function(data){
if("success"==data){
alert("success");
}else{
alert("error");
}
})
url : Requested URL Address
data : Requested data
ranNum : This is the core of cache prevention , Every time a request is made Math.random() Method to generate a random number , This will refresh url cache
This ranNum There are many ways to generate , You can also generate in your own way , Just make sure that the data is generated randomly ! This is it. Ajax Prevent when sending requests url Caching method .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/121290.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢
Explain output analysis of MySQL
How can redis and MySQL data be consistent?
review第1遍,220617,数据仓库DWD层,dwb层,视频,
9. Process communication
Learning Placeholders for Open-Set Recognition
Li Hongyi, machine learning 3 Gradient descent
小程序云开发出坑系列(一)
Cannot open a new task for virtual computer * * *
振动信号的采集与预处理
Opensmax: unknown domain generation algorithm detection ecai2020 open set identification paper interpretation
随机推荐
Leetcode 做题思路笔记
9.进程通信
review第1遍,220617,数据仓库DWD层,dwb层,视频,
Review 1, 220619, Data Warehouse DWB Layer downsize, video,
Applet learning notes - Cloud Development
Judge whether the two time ends contain intersection
review第1遍,220616,数据仓库DWD层,视频,
Oom memory overflow is a classic that we have to watch in actual combat
mysql.user表权限字段说明全介绍
Flex vertical layout elastic compression of applet
Learning Placeholders for Open-Set Recognition
220622_ Preview, knowledge point 10: DWS layer construction -- sales topic wide table -- step1 -- field extraction
Renderdoc frame debugger
Leetcode78 subset explanation
不是我说,不掌握这些坑,你敢用BigDecimal吗?
Swagger (or postman) about the parameter transfer method of date type
SQL中UNION 和 UNION ALL 操作符
How many rows of data can b+ tree algorithm store in MySQL?
Acquisition and pretreatment of vibration signal
One-vs-rest network-based deep probability model for open set recognition解读