Gissipi_453 Gissipi_453 - 4 months ago 26
Ajax Question

Trying to send special characters via JQuery Ajax to PHP script

I'm sending special characters to a PHP file via JQuery Ajax.


var special_charac = '!@#$%^&*()_+-=';
var dataString = 'data=' + special_charac;

type: "POST",
url: "./process.php",
data: dataString,
cache: false,

success: function (result) {




$data= $_POST['data'];
echo $data;


In the PHP file I'm getting all values except + and &

Why is it so ?

Does JQuery Ajax has got some limitations as to what data can you send to PHP script ?


These are not AJAX limitations. These are URL limitations. eg & is used to split parameters. Just send data as json object


data: dataString,


data: {data: special_charac}

or use encodeURI function to escape data

var dataString = 'data=' + encodeURI(special_charac);