Jump to content

IE / Firefox query


woolyg

Recommended Posts

Hi all,

 

Just a quick query regarding the way that IE (specifically 7) handles AJAX calls.

 

I'm using a standard getData call to get info from an external PHP file. It displays fine.

However, if any changes are made to the external PHP file (say, I changed an image on it for display purposes) and I click on the link to call the AJAX in IE, the original image is shown, not the new one.

 

If I do the same thing in Firefox, the new image displays without needing to open a new browser window and 'refresh' the AJAX.

 

Has anyone else had this problem?

Is there an easy fix to make IE show the most up-to-date info in a PHP call?

 

This is really messing with my cross-browser compatibility stuff...!

 

Cheers,

WoolyG

Link to comment
https://forums.phpfreaks.com/topic/127096-ie-firefox-query/
Share on other sites

Use this for image handle for me working.

 


/**
* @GetXmlHttpObject used to detect the browser and set
* xmlHttp
*
*/
function GetXmlHttpObject(){
  var xmlHttp=null;
  try{
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }catch (e){
    // Internet Explorer
    try{
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }catch (e){
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}


/**
* @ajax_php_get used to detect the browser and fix required images
* Function to be called from the main pages.
* ajax_php_get(this.options[this.selectedIndex].value);
* price.options[price.selectedIndex].value + ' ' + this.options[this.selectedIndex].value
*
*/
function ajax_php_get(str1, str2, str3, str4){
  // Set xmlHttp object for browser
  xmlHttp=GetXmlHttpObject();
  // Condition for browser
  if (xmlHttp==null){
    alert ("This browser does not support AJAX!");
    return;
  }
  // Variable setup for php or asp
  var url="callback.php";
  url=url+"?q1="+str1+"&q2="+str2+"&q3="+str3+"&q4="+str4;
  // Must be used , dont change
  url=url+"&sid="+Math.random();

  // Call output function
  if(str1=="2"){
      xmlHttp.onreadystatechange=ajax_php_output1;
  }else{
    xmlHttp.onreadystatechange=ajax_php_output0;
  }
  // Execute GET method
  xmlHttp.open("GET",url,true);
  // Send Get or Post method
  xmlHttp.send(null);
}



/**
* @A B leg
* Dataarrival event
*
*/
function ajax_ab_leg1(vAcmd,vBcmd){

    var Aleg = document.getElementById("a1");
    var Bleg = document.getElementById("b1");

    if (vAcmd == "on"){
        Aleg.src = "img/try.gif";
    }else if(vAcmd == "ring"){
        Aleg.src = "img/talk.gif";
    }else if(vAcmd == "trying"){
        Aleg.src = "img/busy.gif";
    }else{
        Aleg.src = "img/none.gif";
    }

    if (vBcmd=="on"){
        Bleg.src = "img/try.gif";
    }else{
        Bleg.src = "img/none.gif";
    }

}

Link to comment
https://forums.phpfreaks.com/topic/127096-ie-firefox-query/#findComment-657718
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.