如何修复浏览器缓存并notmodified
响应 JSON?jQuery.ajax({ifModified:true,cache:true})
JSON 请求在data
响应时中断。
第一次浏览器请求http://localhost/api返回状态200 OK
和nexts304 Not Modified
$.ajax({
type:"GET",
url:'http://localhost/api', // {"content"="Hello!"}
dataType:'json',
cache:true,
ifModified:true, // Lets respond `304:notmodified`
success:function(data,textStatus,jqXHR){
console.debug(jqXHR.status+':'+textStatus);
console.debug(data); // Why on repeated request returns `undefined`?
}
});
XHR 第一次返回正常:
200:success
Object {content="Hello!"}
但在下一次返回data
undefined:
304:notmodified
undefined
如何解决?似乎是 jQuery 1.5.1 的错误。预期结果:
304:notmodified
Object {content="Hello!"}