Jquery function $.post executes an unresponsive solution under javasciprt


In the process of writing javascirpt program, the $. Post method is used to send data if the characters in the data contain ’< ‘will cause $.post to fail to execute successfully.


var jsonstr='{"value":"abcd<efg"}';
$.post(
url,
{ "jsonstr": jsonstr },
function (data, status) {
});

It needs to be escaped before it can be used. Once escaped using the following transferredChars function, it can be executed by passing the data $.post.

This function USES ’< ‘and’ > ‘respectively replaced by ’< ‘and’ > ’.


transferredChars=function (htmlChars) {
var tcs = htmlChars.replace(/</g, "<");
tcs = tcs.replace(/>/g, ">");
return tcs;
}

var jsonstr='{"value":"abcd<efg"}';
jsonstr=transferredChars(jsonstr);
$.post(
url,
{ "jsonstr": jsonstr },
function (data, status) {
});

The jquery version used is 1.7.1.min