2014-10-07 39 views
-3
<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8"> 
     <title>test</title> 
     <meta name="description" content="test"> 
     <meta name="author" content="test"> 
     <!--Google's CDC for jQuery.--> 
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
     <script type="text/javascript" src="show.js"></script> 
    </head> 

    <body> 

    </body> 
</html> 

$(document).ready(function() { 
    $.getJSON('http://status.leagueoflegends.com/shards?api_key=secretcode', function(data) { 
    alert(JSON.stringify(data)); 
}); 
}); 

当我尝试提醒这一点。只是提醒JSON数据

https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/RiotSchmick?api_key=secretcode

它的工作原理。

但是这个。 http://status.leagueoflegends.com/shards?api_key=secretcode

不起作用。

PS。秘密代码是他们给我们的API密钥。

+2

直接请求浏览器上的网址以知道哪里出了问题。 – mithunsatheesh 2014-10-07 06:29:56

+0

查看您的控制台是否有错误。您的网站是否运行HTTPS? – Spokey 2014-10-07 06:30:48

+1

您可能会收到错误并且不会调用成功处理程序。添加一个错误处理程序到您的请求。 – Krease 2014-10-07 06:31:34

回答

0

由于目前我的声望很低,我必须直接回答,并且不能添加评论。我希望我不打扰任何人。

$ .getJSON - 函数允许您附加多个回调函数。这些函数是'.done()','.always()'和'.fail()'。

$.getJSON('http://status.leagueoflegends.com/shards?api_key=secretcode', function (data) { 
}) 
.done(function(data) { 
    alert(data); 
}) 
.fail(function(jqXHR, textStatus, errorThrown) { 
    alert(errorThrown); 
}); 

查看更多here

现在,你应该能够得到一个更详细的错误消息。 ;)

+0

非常感谢你,学到了新的东西。 :) 它只是显示一个空的警报框? ._。 – nesan101 2014-10-07 07:35:59