In a basic CRUD application saving of Form data is done as follows:
var url;
function newUser(){
$('#jobpos').textbox('clear');
url = 'jobpos.save_user.php';
}
function saveUser(){
$('#fm').form('submit',{
url: url,
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
var result = eval('('+result+')');
if (result.success){
$('#dg').datagrid('reload');
$('#jobpos').textbox('clear');
} else {
$.messager.show({
title: 'Error',
msg: result.msg
});
}
}
});
}
Now if the post data contains a text filed 'jobpos' and during submit if this field contains special character like Single quote ('), Ampersand (&) or Double-quote ("), what I have to do, if I want to save this data into underlying table using the given url/PHP file jobpos.save_user.php ? Generally we use encodeURIComponent() funtion to encode the text value before sending it to backend, but where we can use it, because individual data is not sent in this case, entire form is submitted and all data is found in the PHP file as $_REQUEST data.
Any help regarding where/how I have to use this encodeURIComponent() function to encode text value containg special character ?