开发者

XMLHttpRequest setRequestHeader Error

开发者 https://www.devze.com 2023-03-10 00:48 出处:网络
IE开发者_开发百科 9 developer tools say \"Unspecified error.\" at this line of code: xmlhttp.setRequestHeader (\"If-Modified-Since\", \"Sat 1 Jan 2005 00:00:00 GMT\");

IE开发者_开发百科 9 developer tools say "Unspecified error." at this line of code:

xmlhttp.setRequestHeader ("If-Modified-Since", "Sat 1 Jan 2005 00:00:00 GMT");

I am trying to disable caching of Ajax requests and I don't have control over the server and I cannot append a unique ID to the end of each request, so this looks like my only option. Any ideas why Javascript doesn't like it?


I was calling this before xmlhttp.open (...);. That was the mistake. Modify the header after you open the request, but before you send it.

xmlhttp.open (...);
xmlhttp.setRequestHeader ("...", "...");
xmlhttp.send ();


I don't have too much experience with AJAX requests, but couldn't you just call xmlhttp.setRequestHeader("Cache-Control", "no-cache") instead? Seems like that would make more sense than using the If-Modified-Since header.

0

精彩评论

暂无评论...
验证码 换一张
取 消