I have an issue with JQuery. We are entering test%
in the textfield and called one function on save button.In this function we are serialzing the form data and called AJAX then at server side it is coming as test%
. It is HTML code for %
Could you please help me to resolve the same. I am not able to understand how this is coming.
Below is the code.
function onSave(thisHref)
{
var respData = "";
var id = $("#id").attr("value");
var params = $("#form_used").serialize()+"&ajaxAction=SaveHeader"+"&id="+id;
$.post(ajaxURL, params, function(data){
if(data.length >0)
{
respData = data.substring(data.indexOf("|")+1, data.lastIndexOf("|"));
}
}).complete(function(){
if (respData.length > 0)
{
var responseData = respData.split("|");
var status = responseData[0];
var msg = responseData[1];
if (status == 'SUCCESS')
{
showSuccessMsgHeader(msg);
}
else if (status == 'ERROR')
{
showErrorMsgsOnly(msg);
}
}
});
}
2
Answers
use
.serializeArray()
instead ofserialize()
functionUse jquery’s escape & unescape method
Try this