JQuery, JSON, iframe, and quotation marks do not work together


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
6 views
Produce upload file in an iframe(a different kind of way). In response, generate a JSON object where one of the fields is a string with the html describing the error.
Question: How do I get this response from the server without breaking it?

When I use .text() from JQuery all tags are removed.
When I use .html() from JQuery it "corrects" the html and then it is not possible to do the deserialization of the JSON because the quotes are losing the escape character. we get Invalid JSON.
by | 6 views

4 Answers

0 like 0 dislike
Try on the server before sending to the client the HTML to encode urlencode, JavaScript client om decode using decodeURI or unescape.
by
0 like 0 dislike
As you generate and get json?
For that such data
{"html":"!!!<\\/a>"}

using getJSON everything is displayed normally
\r
\r\r\r\r\r$(document).ready(function() {\r$.getJSON('j.php', '', function (data) {$('body').html(data.html);});\r}\r);\r\r\r\r\r\r
by
0 like 0 dislike
to give in the iframe, not json, and a full html + javascript:
\rparent.callback_func({json: "data"});
\r
by
0 like 0 dislike
innerHTML?
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
4 answers
110,608 questions
257,186 answers
0 comments
28,158 users