ajax - Get JSON data from a PHP file to jQuery and put it on selectbox -
i have big problem here. want receive data php file.
i this:
$("#id_categoria").change(function(){ var id = $(this).val(); $.ajax({ type: "post", url: "<?php echo root . '/control/functions.php'; ?>", data: "action=getsubbycat&id="+id, success: function(data){ alert(data); } }); });
alert(data)
returns [{"id_subcategoria":"1","nome":"port\u00e1teis"},{"id_subcategoria":"2","nome":"desktop"}]
.
and how can consume this? , put in <option value="2">desktop</option>
?
and why portáteis
equal port\u00e1teis
? because database in utf-8?
you use parsejson turn string json object, either build object insert dom using jquery, or document.write() desired output.
Comments
Post a Comment