I would like to know if it is possible to return the ajax call into a javascript array, rather than a DOM object. The ajax call is returning something like n-tuples of value1-value2, and I would like to iterate over that.
Thanks.
$(function () {
$("#categoria").change(function() {
var id = $(this).val();
alert(id);
vars = load("getcategoria.php", "q="+id); // can I do something like this? how?
});
});
Yes you can do this, but .load() is the wrong method for the job. .load() is used to load HTML into a specific DOM element.
I suggest you have your getcategoria.php return a JSON object (use PHP's json_encode), and then use $.getJSON() to get it, parse it, and use it how you wish.
$.getJSON("getcategoria.php", "q="+id, function(data){
// data is your JSON object, use it how you wish
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With