Reputation: 1380
if i have + symbol in comment variable record is not submitted. is there any way i can encode the query string in jquery? i tried some of the methods but they didn't worked
$.ajax({
type: 'post',
url: rootURL + 'services/service.php?method=insertcomment',
data: 'comment=' + comment+'&storyid='+storyid,
dataType: 'json',
success: function (data) {
if(data.code == 200)
$('#success-message')..show();
else
alert('failure');
}
});
Upvotes: 1
Views: 1158
Reputation: 14025
You need to encode your data as URL.
Check the related post : Encode URL in JavaScript?
Or pass your data as JSON object :
$.ajax({
type: 'post',
url: rootURL + 'services/service.php?method=insertcomment',
data: {comment : comment, storyid : storyid},
dataType: 'json',
success: function (data) {
if(data.code == 200)
$('#success-message').show();
else
alert('failure');
}
});
Upvotes: 1