I’m sure this has been asked many times but I couldn’t find the answer after quite a bit of searching.
I have a simple jquery ajax request to get some data for a particular string as follows:
$.ajax(
{ url: "/getval.php?title="+encodeURIComponent(title),
dataType:"json",
success: function(data) { console.log(data) }
});
The php script is using:
$title = urldecode($_GET["title"]);
to get the value from the get request.
It doesn’t need to work for every conceivable string but I do need it to work for a string with a single quote. What is the safest (and easiest) way to do this request and handle the request in php?
Thanks in advance,
Steve
Why hard way?
jQuery:
PHP:
Please always read manual first: