apostrophe issue with ajax post to php
- by Ahmet vardar
hi there,
i am posting data with jquery ajax to php but if input has ' inside, data wont be posted. I tried encodeURIComponent but wont work.
any idea on this ?
thanks
EDIT:
my code
var name = $("input#name_add").val();
name = encodeURIComponent(name);
$.post("function.php", { name: name }, function(data) {
//codes
});
$query = "UPDATE `table` SET name = '" . stripslashes($_POST['name']) . "' WHERE ID = '$id'";
$result = mysql_query($query);
if ($result){
print "ok";
}