Xmlhttprequest In Ie-7
Solution 1:
Sounds like the response is being cached.
Add a psuedo-random string (e.g. a timestamp) to the end of the URI to cache burst.
Solution 2:
you are simply having a caching issue with IE7, as it caches the XMLHttpRequest() after it created it and store it in its memory. even with subsequents xmlhttp=new XMLHttpRequest();
the variable don't get any assigment because it already has an instance (from your first xmlhttp=new XMLHttpRequest();
) .
what you need to do is to invalidate and destroy your XMLHttpRequest request after every use.
you first create your XMLHttpRequest (for msie 7) like this:
functioncreateXMLHttpRequest(){
var xmlHttp = null;
if(typeofXMLHttpRequest != "undefined"){
xmlHttp = newXMLHttpRequest();
}
elseif(typeofwindow.ActiveXObject != "undefined"){
try {
xmlHttp = newActiveXObject("Msxml2.XMLHTTP.4.0");
}
catch(e){
try {
xmlHttp = newActiveXObject("MSXML2.XMLHTTP");
}
catch(e){
try {
xmlHttp = newActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
xmlHttp = null;
}
}
}
}
return xmlHttp;
}
so to create it each time in the function you want to use.
functioncheckDependencyFormFilledStatus(appName,formName){
if(xmlHttp_global){
xmlHttp_global.abort(); // abort the current request if there's one
}
// Create the object each time a call is about to be made
xmlHttp_global = createXMLHttpRequest();
if(xmlHttp_global){
xmlHttp_global.onreadystatechange = myCallbackFunction; // make you callback thing here
xmlHttp_global.open("GET","checkFormDependency.action formName="+formName+"&applicationName="+appName,false);
xmlHttp_global.send(null);
}
}
in your callback ("onreadystatechange" function) you delete it after using it
function myCallbackFunction()
{
if(xmlHttp_global && xmlHttp_global.readyState == 4){
//do your thing here and ... or nothing var dependentFormEmptyStatus = Ext.JSON.decode(xmlhttp.responseText);
alert(xmlhttp.responseText); // like this for example?
xmlHttp_global = null; //delete your XMLHTTPRequest
}
}
so IE 7 will find each time an empty reference and will have the need to recreate it again for each use.
if you don't want to create and delete it eacht time you simply play with some HTTP-Headers in your XMLHTTPRequest
xmlHttp_global.setRequestHeader("If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT");
xmlHttp_global.setRequestHeader("Cache-Control", "no-cache");
like suggested here
Another alternatives include:
Using POST method over GET method
xmlHttp_global.open("POST","checkFormDependency.action",false); xmlHttp_global.setRequestHeader("Content-type","application/x-www-form-urlencoded"); // or another content type , its up to you xmlHttp_global.send("formName="+formName+"&applicationName="+appName);
Using a "dummy" variable in your query-String to burst out the cacher of IE(7,6)
xmlHttp_global.open("GET","checkFormDependency.action formName="+formName+"&applicationName="+appName+"randomVar="+Math.Random(),false);
Links
Post a Comment for "Xmlhttprequest In Ie-7"