The encodeURIComponent() function encodes a URI component. This function encodes special characters. In addition, it encodes the following characters: , / ? : @ & = + $ #
var title = $('#title').val();
var description = $('#description').val();
jQuery.ajax({
type: "POST",
url: "save.php",
data: "title=" + encodeURIComponent(title) + "&desscription=" + encodeURIComponent(desscription)
}); |
var title = $('#title').val();
var description = $('#description').val();
jQuery.ajax({
type: "POST",
url: "save.php",
data: "title=" + encodeURIComponent(title) + "&desscription=" + encodeURIComponent(desscription)
});
<?php
$title = preg_replace('/%([0-9a-f]{2})/ie', "chr(hexdec('\\1'))", $controller->title);
?> |
<?php
$title = preg_replace('/%([0-9a-f]{2})/ie', "chr(hexdec('\\1'))", $controller->title);
?>