Hello,
I faced an issue while executing file by sending url through ajax code in ie and i have posted below how i rectified issue, i think this will help you.
CODE TO CREATE AJAX REQUEST OBJECT
function createRequestObject(){
var request_o; //declare the variable to hold the object.
if(browser == "Microsoft Internet Explorer"){
/* Create the object using MSIE's method */
request_o = new ActiveXObject("Microsoft.XMLHTTP");
}else{
/* Create the object using other browser's method */
request_o = new XMLHttpRequest();
}
return request_o; //return the object
}
CODE TO CALL FILE 'ajax1.php' BY USING AJAX FUNCTION
function testAjax(tnam,scri,gp,cat,desc,opr)
{
httpa = createRequestObject();
var str="ajax1.php?name="+tnam;
httpa.open('get', str);
//alert(str);
httpa.onreadystatechange = handleResponse2;
/* Send the data. We use something other than null when we are sending using the POST
method. */
httpa.send(null);
}
FUNCTION TO PRINT THE RESPONSE AFTER EXECUTING THE FILE
function handleResponse() {
if(httpa.readyState == 4){
var response = httpa.responseText;
alert(response);
//CODE TO INSERT THE NEW PROFILE
IF THE PASSED PROFILE NAME DOES NOT EXIST
}
For the first time when testAjax() function is called it opens the file ajax1.php and query the table to find the profile for the passed name,
if the profile doesnot exist it creates the new profile and sends the inserted response. When the newly added profile name is selected for display in internet explorer it does not display profile ie, empty response is send to handleresponse() function, but when selected in Firefox it displays the profile.
The above issue is because for the first time when profile name which does not exist in the database is given it displays empty response, this is saved in cache. So even after this profile is added, when the same url is passed it fetches previous response from cache and display empty response instead of displaying added profile.
I rectified this issue by adding time along this url, so when each time this url is passed with different time vale, the url will looks different. So you will not get result from cache.
URL IS APPENDED WITH TIME TO AVOID CACHE ISSSUE IN IE
function testAjax(tnam,scri,gp,cat,desc,opr)
{
httpa = createRequestObject();
var mytime= "&ms="+new Date().getTime();
var str="ajax1.php?name="+tnam+mytime;
httpa.open('get', str);
httpa.onreadystatechange = handleResponse2;
httpa.send(null);
}
|