From my database i fetched some data as json string.But unfortunately i can't access the data which is returned as response. Following is my php page to fetch data:
require_once '../core/init.php';
$answer=$_POST['answer_body'];
$post_id=$_POST['userpost_post_id'];
$answerer=$_POST['users_user_id'];
if(isset($answer,$post_id,$answerer)){
if(!empty($answer) && !empty($post_id) && !empty($answerer)){
$db=DB::getInstance();
if($result=$db->post_and_fetch("CALL login.post_and_fetch_ans(?,?,?)",array($answer,$post_id,$answerer))->result()){
echo json_encode($result);
}else{
echo 'there was a problem';
}
}
}
It returned as following:
and in the receiving part is following:(it currently prints undefined)
$.ajax('../includes/verifyanswer.php',{
data:data,
type:"POST",
datatype:'json',
success:function(response){
alert(response['answer_body']); // prints undefined
},
error:function(response){
alert(response);
}
})