heres my code so you see what i’m trying to do, which obviously isn’t working:
$('#selector').change(function() {
if ($(this).val().length > 0)
{
$.ajax({
type: "POST",
url: "ajax.php",
data: "id="+$(this).val(),
success: function(data){
if (data != 'error')
{
$('#main_url').val(data[2]);
$('#main_url_title').val(data[3]);
}
}
});
}
});
i set up an alert(data); and all it pops up with is “Array”. so now my 2 fields are being populated with “r” and “a”…what is the correct way of doing this?
I think you may encode php array in json data, and then use json with jquery
Add in ajax.php something like
echo json_encode($your_php_array)