I am using .ajax() to send a request to the server. The server is using PHP to process the request.
According to php urldecode, $_REQUEST is already decoded and Plus symbols ('+') are decoded to a space character.
What I have found is that Plus symbols are being decoded to a underscore ('_'). This is true for both + and %20. Is there any way around this? This seems like unexpected behavior.
Code sample for what its worth:
ajax:
$.ajax({
url: 'mySite.php',
method: 'POST',
data: $(this).serialize()
});
php:
$myVar = "Veh #";
if (isset($_REQUEST["$myVar"])){
//do stuff
}
//to see request
var_dump($_REQUEST);
The var_dump gives
array(1) {["Veh_#"]=> string(1) "6"}
I would expect is to be
array(1) {["Veh #"]=> string(1) "6"}
fiddler data posted:
Veh+%23=6