Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem updating select tag with ajax on IE
    text
    copied!<p>I have a problem with inner html funcion when updating tag options. In the first select tag I am chosing a country and ajax code must update cities in the other select tag. My code works in all major browsers except IE. Here is the js code for calling php script:</p> <pre><code>&gt;function show_zones(str) &gt;{ &gt;if (window.XMLHttpRequest) &gt; {// code for IE7+, Firefox, Chrome, Opera, Safari &gt; xmlhttp=new XMLHttpRequest(); &gt; } &gt;else &gt; {// code for IE6, IE5 &gt; xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); &gt; } &gt;xmlhttp.onreadystatechange=function() &gt; { &gt; if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) &gt; { &gt; document.getElementById('region_to').innerHTML=""; &gt; jQuery.noConflict(); &gt; (function($) { &gt; $('#region_to').append(xmlhttp.responseText); &gt; })(jQuery); &gt; alert(xmlhttp.responseText); &gt; } &gt; } &gt;xmlhttp.open("GET","ajax/zones.php?country="+str,true); &gt;xmlhttp.send(); &gt;} </code></pre> <p>In all browsers alerted code returns appropriate option tags but in IE it returns "Undifined". I am using Jquery to append xmlhttp.responseText because IE does not support innerhtml for select tags. noConflict function is used to avoid conflict between mootolls and jquery libraries. I can`t just place select tag in a div and print it instead of printing just options because I am using custom select which is being created by js code when the window.onload event occurs.</p> <p>here is the php code:</p> <pre><code>&gt;require_once("../../connect.php"); &gt;$country_query="SELECT* FROM `tour_countries` WHERE &gt;country_name='".$_GET['country']."'"; &gt;$country_result=mysql_query($country_query); &gt;$country_row=mysql_fetch_array($country_result); &gt;$zone_query="SELECT* FROM `tour_zones` WHERE country_ID='".$country_row[0]."'"; &gt;$zone_result=mysql_query($zone_query); &gt;while($zone_row=mysql_fetch_array($zone_result)) &gt;{ &gt; echo '&lt;option value="'.$zone_row[1].'"&gt;'.$zone_row[1].'&lt;/option&gt;'; &gt;} </code></pre> <p>Thanks for replys and sorry for my poor englesh.</p>
 

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