我尝试使用jQuery进行AJAX调用,数据中有特殊字符,例如{'data':'<p>test</p>'}
。似乎一开始就无法传递此数据。如果只传递{'data':'test'}
,它将起作用。由于特殊字符<>/
,encodeURIComponent和JSON.stringify在此处失败。
请问有谁可以帮忙解决吗?谢谢。
$.ajax({
type: "POST",
url: "services.aspx",
data: "data=" + encodeURIComponent(JSON.stringify(obj)),
dataType: "text",
error: function(xhr, textStatus, errorThrown) {
alert("ERROR"); },
success: function(data)
{
}
});
敬礼,
大卫