Javascript 无法使用getJSON检索数据

Javascript 无法使用getJSON检索数据,javascript,jquery,ajax,html,Javascript,Jquery,Ajax,Html,这是我的网页代码 <html> <head> <script src="jquery-1.7.2.js"></script> </head> <body> <script> var url = "https://natiweb-natiweb.rhcloud.com/game.php"; $.getJSON(url,function(data){ $.each(data,funct

这是我的网页代码

<html>
<head>
<script src="jquery-1.7.2.js"></script>
</head>

<body>
<script>
var url = "https://natiweb-natiweb.rhcloud.com/game.php";
 $.getJSON(url,function(data){
              $.each(data,function(i,user){
alert("inside json");
    alert(user.appname);
               });
            }
        );

</script>

</body>
</html>

变量url=”https://natiweb-natiweb.rhcloud.com/game.php";
$.getJSON(url、函数(数据){
$。每个(数据、函数(i、用户){
警报(“内部json”);
警报(user.appname);
});
}
);
我无法从服务器获取数据。。。。警报不会弹出 如果我在js文件中编写脚本代码,效果很好。但我需要动态地填充一个页面,因此我需要在主体内部编写这个查询。 我在json函数中添加了警报。即使是这样,也没有被人发现。我认为json没有得到执行

试试这个

var url = "https://natiweb-natiweb.rhcloud.com/game.php";
 $.getJSON(url,function(data){
   $.each(data,function(i,user){
    alert(user.appname[i]);
           });
        }
    );

试试这个,因为你的json所在的数组中有数组

alert(user[0].appname);

尝试自动执行代码,这就是jquery文档中的示例所说的

<script>
(function() {
var url = "https://natiweb-natiweb.rhcloud.com/game.php";
$.getJSON(url,function(data){
$.each(data,function(i,user){
alert("inside json");
alert(user.appname);
           });
        }
    );  

})();
</script>

(功能(){
变量url=”https://natiweb-natiweb.rhcloud.com/game.php";
$.getJSON(url、函数(数据){
$。每个(数据、函数(i、用户){
警报(“内部json”);
警报(user.appname);
});
}
);  
})();

控制台中是否有任何错误??