Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had the same issue with IE and .innerHtml() with ajax calls. I solved it by making the AJAX a POST request and using jQuery .html() instead of .innerHTML(), for some reason IE is pretty glitchy with innerHtml(). Here's the working function I used:</p> <pre><code>function getCitiesFromState(state, select, spinnerNum) { if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } var ran = Math.round((new Date()).getTime() / 1000), terms = "state="+state+'&amp;r='+ran; xmlhttp.open("POST","ajax5.php",true); xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); /*********************************************************** * These two lines cause Chrome to throw non-fatal errors. * Removing them didn't change the functionality of the * request, but this may end up needing a conditional. ***********************************************************/ //xmlhttp.setRequestHeader('Content-length', terms.length); //xmlhttp.setRequestHeader('Connection', 'close'); xmlhttp.onreadystatechange = function() { $('#spinner'+spinnerNum).fadeIn(300); if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { $('#spinner'+spinnerNum).fadeOut(100); $('#'+select).html(xmlhttp.responseText); } } xmlhttp.send(terms); } </code></pre> <p>And the ajax5.php file:</p> <pre><code>&lt;?php include 'db.class2.php'; $DB = new DB_MySql2; $DB-&gt;connect(); $state = mysql_real_escape_string($_POST['state']); $q = $DB-&gt;query("SELECT DISTINCT `city`, `zip_code` FROM `usa_master` WHERE `state` = '".$state."' GROUP BY `city` ORDER BY `population` DESC LIMIT 0, 150"); while($r = $DB-&gt;fetch_assoc($q)) { $city[] = $r['city']; $zips[] = $r['zip_code']; } array_multisort($city, $zips); echo '&lt;option value="" selected="selected"&gt;Select City&lt;/option&gt;'; $size = sizeof($city); for ($x = 0; $x &lt; $size; $x++) { if (strlen($zips[$x]) == 4) { $zips[$x] = '0' . $zips[$x]; } echo '&lt;option class="city_list" value="'.$zips[$x].'"&gt;'.$city[$x].'&lt;/option&gt;'; } ?&gt; </code></pre> <p>Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload