I am using this code to send response to a request:
$data; //some array
$data
has values like
array(4) (
[nextAvail] => (bool) true
[thisAvail] => (bool) true
[count] => (int) 15
[stream] => (string) [html body goes here]
)
I am using:
echo json_encode($data);
but surprisingly response I received at browser like:
{"nextAvail":true,"thisAvail":true,"count":15,"stream":null}
I am using jquery post to make request:
$.post(ajaxPath, {
data: data
},
function(data) {
}, "json")
Please suggest what could possibly go wrong while sending response using json_encode, I tested sending response by removing json_encode and simply using
echo print_r($data);
it's sending response with no issues.