php - Embedding JSON in responseText -
I am using jquery iframetransport (to upload Blob) and to access my responses through data I am compelled to I am able to embed simple JSON from my PHP such as
echo json_encode (array ("feedback" => "hello"));
and my console will return the log
{"response": "hello"}
but I need To collect data from Divs and my PHP requests If I try to embed it, then I immediately fail:
echo json_encode (array ("feedback" => gt; & lt; div & gt; hello & lt; / Div & gt; "));
I
ends with "response": "hello "}
< / Pre>What can I do for this kind of Jason data in Resposnetext?
Alternatively you can enter htmlentities ()
for the response code Like this:
echo json_encode (array ('response' = & gt; htmlentities ('& lt; div & gt; hello & lt; / div & gt;'))); // {"Response": " Hello "} Exit; On retrieving the responses, when you are expecting JSON, then data type:
add property:
$ Ajax ({Url: 'blahblah.php', data type: 'JSON', // this one});
Comments
Post a Comment