I have a form that is composed of a couple of text fields and a textarea for order notes/comments . The problem that I have is that every time I type a special character in the textarea the ajax request stops working. I've tried to escape the special characters using escape, escapeURIComponent, etc, but nothing seems to work. Removing the special characters works, but that doesn't solve my problem. Any suggestions? below is a snippet of the code I have:
$.post(getPost('addComponent'), {
componentType:$('#componentType').val(),
productQty:$('#productQty').val(),
comments:$("#orderNotes").val()
}, function(data, statusCode) {
if (statusCode === 'success') {
updateComponentContainer(data);
} else {
return false;
}
}, 'json');
Have a look at jQuery.serialize()
http://api.jquery.com/serialize/
** EDIT **
Look at this jsFiddle:
Not sure what the special characters are, but base64 encoding should solve the problem.
http://www.webtoolkit.info/javascript-base64.html
and if you like to try before you buy, the demo page!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.