Ajax Issue with IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adamjblakey
    New Member
    • Jan 2008
    • 133

    Ajax Issue with IE

    Hi,

    I am running the following code on my website:

    Code:
    function showHint2(str)
    {
    if (str.length==0)
      { 
      document.getElementById("txtHint").innerHTML="";
      return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
    	document.getElementById('course').innerHTML = xmlhttp.responseText;
        }
      }
      
      var params = [];
    
    params.push("q=" + str);
    params.push("u=" + document.getElementById("university").value);
    params.push("w=" + document.getElementById("university2").value);
    
    var url = "update-course.php?" + params.join("&");
      
      infoStr = str+"&u="+document.getElementById('university').value+"&w="+document.getElementById('university2').value;
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
    }
    Code:
    require_once('init.php');
        
        //get the q parameter from URL
        $choice=$_GET["q"];
        $uni=$_GET["u"];
        $uni2=$_GET["w"];
        
        if ($choice == 'Postgraduate'){
            $year_of_study = "Postgraduate";
        }else{
            $year_of_study = "Undergraduate";
        }
         
        if ($uni2 == '-1'){ 
        $query = mysql_query("SELECT * FROM universities WHERE year_of_study = '$year_of_study' AND university = '$uni'");
        }else{
        $query = mysql_query("SELECT * FROM universities WHERE year_of_study = '$year_of_study' AND university = '$uni2'"); 
        }
        while ($row = mysql_fetch_array($query))
                {
                 print "<option value='" . $row['course'] . "'>" . $row['course'] . "</option>";
                }
    The code is designed to load results into a select box once the user has selected an option from a previous select box. E.g. someone selects Ford and all the options in the database under the make ford loads.

    Which works fine on all browsers except IE. Does anyone have any ideas why this would not work on IE?

    Cheers,
    Adam
  • NitinSawant
    Contributor
    • Oct 2007
    • 271

    #2
    use jquery to make ajax calls

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      This seems to be a caching issue. Add a unique timestamp to the URL request.

      Comment

      Working...