I have an AJAX call:
$.ajax({
type : "POST",
dataType : 'JSON',
url : "../hotelroomtype",
data : form_data,
success : function(data){
var datas = $.parseJSON(data);
alert(datas['categorys'].categorytype0)
// var returnedData = $.parseJSON(data);
// alert(returnedData);
// $('.x').html(returnedData);
//
// for(i=1;i<oldSeason;i++){
// $('#roomcategory'+i).html(data.categorytype+i);
// }
}
});
Server returned to my js the following JSON data
[{"categorytype0":"<div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div>"},{"categorytype1":"<div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div><div class='panel-body'>adfdfs<\/div>"}]
When I check with alert it only shows [object object]
. Where is the problem?
Edited: AJAX call:
$.ajax({
type : "POST",
url : "../hotelroomtype",
data : form_data,
success : function(data){
dataType : 'JSON',
for(i=1;i<oldSeason;i++){
$('#roomcategory'+i).html(data.categorytype+i);
}
}
});
here i get the result, but not in proper way.I need the result in categorytype wise. but it is in array..i can't get it separatly
here is my json call
$data = array();
for($i=0;$i<$cnt;$i++)
{
array_push($data, array('categorytype'.$i.'' =>$roomtype));
}
echo json_encode($data, JSON_UNESCAPED_SLASHES);