Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.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
当PHP生成JSON时,jQuery不会将JSON对象返回给Firebug_Php_Jquery_Json_Firebug - Fatal编程技术网

当PHP生成JSON时,jQuery不会将JSON对象返回给Firebug

当PHP生成JSON时,jQuery不会将JSON对象返回给Firebug,php,jquery,json,firebug,Php,Jquery,Json,Firebug,test.json的内容包括: {"foo": "The quick brown fox jumps over the lazy dog.","bar": "ABCDEFG","baz": [52, 97]} 当我使用以下jQuery.ajax()调用来处理test.JSON中的静态JSON时 $.ajax({ url: 'test.json', dataType: 'json', data: '', success: function(data) {

test.json的内容包括:

{"foo": "The quick brown fox jumps over the lazy dog.","bar": "ABCDEFG","baz": [52, 97]}
当我使用以下jQuery.ajax()调用来处理test.JSON中的静态JSON时

$.ajax({
    url: 'test.json',
    dataType: 'json',
    data: '',
    success: function(data) {
        $('.result').html('<p>' + data.foo + '</p>' + '<p>' + data.baz[1] + '</p>');
    }
});
我在浏览器中获得了正确的输出,但Firebug只显示HTML。在Firebug中展开GET请求时,不存在JSON选项卡。

试试看

<?php
    header('Content-type: application/json');
    $arrCoords = array('foo'=>'The quick brown fox jumps over the lazy dog.','bar'=>'ABCDEFG','baz'=>array(52,97));
    echo json_encode($arrCoords);
?>

试试看


您最有可能需要设置内容类型标题:

// this is the "offical" content-type
header('Content-Type: application/json');
// or - this will probably work too
header('Content-Type: text/javascript');

您最有可能需要设置内容类型标题:

// this is the "offical" content-type
header('Content-Type: application/json');
// or - this will probably work too
header('Content-Type: text/javascript');

查看响应选项卡上的响应选项卡
// this is the "offical" content-type
header('Content-Type: application/json');
// or - this will probably work too
header('Content-Type: text/javascript');