I write a script to make an ajax call here is my code
function ajax_post(obj) {
obj = '#'+ obj;
var formData = $(obj).serializeArray();
$.ajax({
url: '__core/info.php',
type:'get',
dataType: 'json',
data: formData,
success: function(resp){
alert(resp);
}
})
}
and here is my info.php
$last_Res = theme::get_last_themes_desk(); //$last_Res is an array
echo(json_encode($last_Res));
but when alert it shows return object object ….. what should i do if datatype is json should i convert it to another format ? $last_Res is an array
In response to your comment (showing the response data, which is an array, containing a single object):
Will serve you just fine…
$last_Resis an associative array, most likely. JS doesn’t have assoc arrays, but converts these to objects/ object literals:That’s all there is too it. To access the data: