Jquery ajax json响应未显示
嘿,我所有的代码如下: JS: 我的master.php有:Jquery ajax json响应未显示,ajax,jquery,json,Ajax,Jquery,Json,嘿,我所有的代码如下: JS: 我的master.php有: <?php $called = $_POST['called']; if ($called == 'REG') { $json = array('good' => 'the value here'); header("Content-Type: application/json", true); echo json_encode($json); } ?> 我得到的控制台输出如下: g
<?php
$called = $_POST['called'];
if ($called == 'REG') {
$json = array('good' => 'the value here');
header("Content-Type: application/json", true);
echo json_encode($json);
}
?>
我得到的控制台输出如下:
good:null form.php:102
good3:[对象]form.php:103
古德3:成功
我会缺少什么?您使用的是POST方法,但是访问PHP脚本中的$\u GET数组时,不要在success函数中调用
jQuery.parseJSON()。当您指定数据类型:“json”
时,jQuery会自动为您执行此操作。为什么要在$.ajax()调用中设置contentType?只是让它以正常的方式发送参数。将其更改为POST,但仍然没有得到任何结果。
<?php
$called = $_POST['called'];
if ($called == 'REG') {
$json = array('good' => 'the value here');
header("Content-Type: application/json", true);
echo json_encode($json);
}
?>