jquery timer플러그인을 이용해 10초 마다 서버쪽으로 ajax request를 보내는 코드가 있었는데
이상하게 IE에서는 불특정하게 서버쪽으로 request가 나가지 않았다. (파폭에서는 이상없음)
$(document).everyTime('10000', "AAAThread", function() {
$.get("/blahblahblah.do",
{
"parm1": $("#parm1").val()
}, callbackfunction,"json");
});
});
callbackfunction은 호출이 되는데 blahblahblah.do 로 리퀘스트가 넘어가지 않았다.
즉, IE가 캐쉬를 가져온 것이다. 구글링을 통해 검색해 보니 IE에서 ajax콜이 캐쉬를 가져오는 문제가 있는 것 같고 가장 빠른 해결책은 post 방식을 사용하는 것이었다. 다른 해결책이 있는지도 모르겠지만
일단 위의 코드를 post방식으로 바꿔서 캐슁문제를 해결할 수 있었다.
$(document).everyTime('10000', "AAAThread", function() {
$.post("/blahblahblah.do",
{
"parm1": $("#parm1").val()
}, callbackfunction,"json");
});
});
Ajax IE Caching Issue
David Arthur, like many, has had problems with the caching issue that Internet Explorer seems to have with Ajax connections:
If you’ve been working with the Ajax framework long enough, i’m sure you’ve run into at least a few speed bumps thanks to Internet Explorer. Not a day goes by that i don’t have to rewrite a line of code, or tweak my css in order for IE to render what i think it should. But alas, this is the nature of software that comes from a company that views Standard Compliances as recommendations.
He describes his problem – grabbing a new image with an Aajx request, a seemingly simple task – and the results of his queries. IE decided caching it was the “in” thing and wasn’t going to grab anything new. He tried all sorts of hacks and fixes to try to get things working, but to no avail. Finally, after finding this entry on Wikipedia, he stumbled across a solution – using POST over GET.
While he was figuring it out, though, there were also lots of comments being made to the original post with hacks to get around the issue – so many that he wanted to create a new place for them all to be shared. In this post he includes two of the suggestions, including using something like a timestamp to change up the URL and adding in an unused POST variable.
'IT_Programming > JavaScript' 카테고리의 다른 글
자바스크립트 완벽사이드 - 9.6 상속 없이 확장하기 (0) | 2011.04.29 |
---|---|
자바스크립트 완벽가이드 - 9.5 슈퍼 클래스와 서브 클래스 (0) | 2011.04.29 |
IE 에서 location.href 를 쓰는 경우 referer 값을 제대로 받아오는 방법 (0) | 2011.04.03 |
가우시안 (정규분포) 난수 생성 예제 (0) | 2010.12.14 |
[펌] GET 방식과 POST 방식 (0) | 2010.12.07 |