我在我的例子中使用AJAX。在这里我使用了cache: false
属性。
它总是触发请求(我在网络选项卡中检查)。为什么请求没有缓存?这是我的代码
http://codepen.io/anon/pen/WGgKvd?editors=1010
$(function(){
$('#btn').click(function(){
alert('----')
$.ajax({
url: "https://api.github.com/events",
data: {
id: 123
},
cache: false,
type: "GET",
dataType : "json",
}).done(function(json) {
$("<h1>").text(json.title).appendTo("body");
$("<div class=\"content\">").html(json.html).appendTo("body");
}).fail(function(xhr, status, errorThrown) {
alert("Sorry, there was a problem!");
console.log("Error: " + errorThrown);
console.log("Status: " + status);
console.dir(xhr);
}).always(function(xhr, status) {
alert("The request is complete!");
});
})
})