let's say we have the following ajax:
$.ajax({
url:'myURL.php',
data:{
ac:'do',
isDoable:false
}
});
Now at the back end when reading the call data, the isDoable
is a string, and trying to cast it as Boolean:
$isDoable = (bool) $_REQUEST['isDoable'];
results in $isDoable
always being true
, even when sent as false
.
When I encountered this issue I gave up and simply treated it as a string if($_REQUEST['isDoable'] == 'true')
But I cannot get over it! why is this unexpected behavior, and is there a way around it?