jQuery AJAX call undefined error with special characters
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2009-09-21T08:33:59Z
Indexed on
2010/04/26
6:03 UTC
Read the original article
Hit count: 428
Hi,
I tried to make an AJAX call using jQuery, the data has special characters, e.g {'data':'<p>test</p>'}
. It seems failed to pass this data in the first place. It will work if i just pass {'data':'test'}
. encodeURIComponent and JSON.stringify failed here due to the special character < > /
.
Could anyone please help with it? Thanks.
$.ajax({
type: "POST",
url: "services.aspx",
data: "data=" + encodeURIComponent(JSON.stringify(obj)),
dataType: "text",
error: function(xhr, textStatus, errorThrown) {
alert("ERROR"); },
success: function(data)
{
}
});
Regards,
David
© Stack Overflow or respective owner