I am using a jquery ajax call which accepts json response :
var posturl = '/admin/getparamdetails/';
var data = "adnetworkId="+adnetworkId;
$.ajax({
type: "POST",
url: posturl,
data : data,
datatype: "json",
success: function(msg){
//$("#displayPramForm").html(msg);
//alert('hello'+msg.length+' '+msg.hello.length);
console.log(msg);
if(msg!='')
{
alert(msg.hello);
}
},
failure: function(msg){}
});
in my php backend function , I am using json_encode on a simple array as shown:
$json_encoded_string = json_encode(array("hello"=>'abc'));
echo $json_encoded_string;
die;
but alert(msg.hello) returns undefined for me. What is going wrong here ? Also , in my console.log I am able to get the output as :
{"hello":"abc"}