var jsonstr='{"value":"abcd<efg"}';
$.post(
url,
{ "jsonstr": jsonstr },
function (data, status) {
});
需要將其轉義後再使用,使用下面的transferredChars函數轉義後,再傳遞數據$.post即能執行。
此函數使用將'<'和‘>'分別替換爲’<'和‘>'。
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) {
});
使用的jquery版本爲1.7.1.min