I am trying to retrieve the following json generated in my php script uing jquery. However, I am not being able to display it. If I alert it, it just displays 'undefined'. Using $('#demo').html(data.htmlOutput) to display the html doesn't do anything either. Please can someone point out what I'm doing wrong?
$arr = array('htmlOutput' => '<b>hello</b>', 'no_rows' => 'balh');
echo json_encode($arr);
$.post('get-offers.php', $("#offerForm").serialize(), function(data) {
alert (data.htmlOutput);
alert (data.no_rows)
$('#demo').html(data.htmlOutput);
}
I can see the json response in the FB console,however, it still does nothing.