我认为我在最新的jQuery 3.3.1中发现了错误。我的问题看起来像这样-当我尝试使用getJSON函数将索引作为数字0或字符串0发送时,我没有得到任何响应。尝试其他数字或字符串,效果很好。
我的js:
var index = 0;
$.getJSON('/ajax.php' , { index: index }, function(r) {
console.log( r );
}, 'jsonp');
我的示例php:
header('Content-Type: application/json');
$index = intval( $_GET['index'] );
file_put_contents('log.txt' , $index);
die(json_encode([
'received' => $index
]);
在log.txt中,我发现了0和其他要发送给我的数字,但是如果0为索引,那么我在console.log json中没有看到json响应{received:0}