Note that there are some explanatory texts on larger screens.

plurals
  1. POempty drop down fields appearing after decoding ajax response to drop down
    primarykey
    data
    text
    <p>i am getting a json like this after using an ajax to call a web service,i have decoded the json to alert each value as employee and temporary one after the other,now i would like to bring these values into the drop down field of a form with the id ultra,i am getting 2 empty fields for the drop down +the va;ues i ahve decoded .My json response in items is </p> <pre><code>["Employee","Temporary"] </code></pre> <p>my codd for ajax calling and decoding the result and alerting each element in the return json</p> <pre><code>function ajax(){ var loc=document.getElementById('category_id1').value; alert(loc); var req; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari req=new XMLHttpRequest(); }  else  {// code for IE6, IE5 req=new ActiveXObject("Microsoft.XMLHTTP"); } req.open("POST", "ajax.php?&amp;loc="+loc+"", true); req.send(); var html req.onreadystatechange=function(){ if(req.readyState==4&amp;&amp;req.status==200){ //$(".error").hide(); result=req.responseText //alert(result); var items = JSON.parse(result); //alert(items.length) for(var i=0; i&lt;items.length; i++) { var item = items[i]; //alert(item); html=html+"&lt;option value="+item+"&gt;"+item+"&lt;option&gt;" } } document.getElementById("Ultra").innerHTML=html } } &lt;form&gt; &lt;label for="subcategory"&gt;Sub Category&lt;/label&gt; &lt;select style="width:305px" name="subcategory" id="Ultra" onchange="run()"&gt; &lt;option value=""&gt;Select&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p>the form field  after on the same page is i dont get empty field here what i am doing wrong Thank you</p>
    singulars
    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.
 

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