问题描述
我使用的JQuery AJAX请求发送到我的动作类数据:{campaignId:campaignId}
,但 _ = 1389258551926
也以数据。
I am using JQuery ajax to send request to my action class with data: {campaignId: campaignId}
but _=1389258551926
also sent as data.
我的Ajax请求的功能是:
My ajax request function is:
$('#submit').click(function() {
var campaignId = $('#campaign').val();
alert("Ajax request ; Camp : " + campaignId);
$.ajax({
type: "get",
url: "getCampData",
data: {campaignId: campaignId},
dataType: "json"
}).done(function(data) {
alert("Camp List : " + data.campList);
});
查询字符串参数:
Query String parameters:
campaignId=Test&_=1389258551927
为什么要以数据这个额外的参数?
Why this extra parameter sent as data?
推荐答案
此参数是一个时间戳。你可以看到它的奇怪的是一样的你会得到在控制台
This parameter is a timestamp. You can see it's strangely alike what you'd get in the console with
Date.now()
这是为了确保网址的变化,避免接收页面的缓存版本。
This is done to ensure the URL changes and avoid receiving a cached version of the page.
这在文档:
缓存(默认:true,false为dataType的脚本和JSONP')
类型:Boolean如果设置为false,这将迫使请求的页面不被 由浏览器高速缓存。注意:设置缓存为false将只工作 正确的头部和GET请求。它的工作原理通过附加 _ = {}时间戳的GET参数。参数不需要用于 其他类型的请求,但在IE8在一个职位做一个网址 已被要求由GET。
Type: Boolean If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
这篇关于为什么" _ = 1389258551926"发送作为Ajax请求的查询字符串参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!