Why does this ajax fail when html tags are added to the json, if the <br />
is not there then is works. The only work around that I can think of is by encoding the text.
Do you know why or /and have any other suggestions.
Thanks
$.ajax({
type: "POST",
url: "/url",
//data: { "myText" : '[{ "a": "test1", "b": "test2"}]' },//works
data: { "myText": '[{ "a": "<br />dfgdfgdfgdfgdgd", "b": "test2"}]' },//causes error
dataType: 'json',
success: function (data) {
alert("pass");
},
error: function () {
alert("error");
}
});
is the HTML tag and
is XHTML. Possibly your parser is being very strict? – Cliff Ribaudo Aug 12 '12 at 15:37