When writing a javascirpt program, use the $.post method to send data. If the characters in the data contain '<', $.post will not be executed successfully.
var jsonstr='{"value":"abcd< efg"}';
$.post(
url,
{ "jsonstr": jsonstr },
function (data, status) {
});
It needs to be escaped before use. After escaping using the transferredChars function below, pass the data $.post to execute.
This function replaces '<' and '>' with '<' and '>' respectively.
transferredChars=function (htmlChars) {
var tcs = htmlChars.replace(/tcs = tcs.replace(/>/g, ">");
return tcs;
}
var jsonstr='{"value" :"abcdjsonstr=transferredChars(jsonstr);
$.post(
url,
{ "jsonstr": jsonstr },
function (data, status ) {
});
The jquery version used is 1.7.1.min
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn