Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ajax json响应未显示_Ajax_Jquery_Json - Fatal编程技术网

Jquery ajax json响应未显示

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

嘿,我所有的代码如下:

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);
}
?>

我得到的控制台输出如下:

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);
}
?>