I’m making requests to my server using jQuery.post()
and my server is returning JSON objects (like { var: value, ... }
). However, if any of the values contains a single quote (properly escaped like '
), jQuery fails to parse an otherwise valid JSON string. Here’s an example of what I mean (done in Chrome’s console):
data = { status: success, newHtml: Hello \'x };
eval(x = + data); // { newHtml: Hello 'x, status: success }
$.parseJSON(data); // Invalid JSON: { status: success, newHtml: Hello 'x }
Is this normal? Is there no way to properly pass a single quote via JSON?