无法读取来自 insta 的 json

can't read a json come from insta

我做了一个这样的项目,但在解析中 json 文件来自 instagram api 我看不懂 我的代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>tst</title>
<script src="../jq.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $(".send").click(function(){
        var name =  $("#name").val();
        var my_url= "https://api.instagram.com/v1/tags/"+name+"?access_token=2307573123.2c01fc8.d2a19d4145c84d59962c0db8d418d2a8";
        $("#name").val("");
        $.ajax({
            type: 'GET',
            url: my_url,
            dataType: 'jsonp',
            function(response){
                //how????
            }
            });
        });
    });
</script>
</head>
<body>
  <p id="p1"></p>
  <input type="search" id="name" />
  <input type="button" class ="send"  value="send" />
</body>
</html>

我只想读一篇文章。我可以解析它,但我看不懂。 //我放how???的地方是我阅读的地方

API 响应包含数据 属性 :

获取:https://api.instagram.com/v1/tags/Whosebug?access_token=xxx

{"data": {"name": "Whosebug", "media_count": 10769}, "meta": {"code": 200}}

要访问值:

success:function(response){
  //how????
  alert(response.data.name + ' have ' + response.data.media_count + ' media');
}

您在 ajax 调用中出错,没有得到正确的响应,它应该是这样的:

$(document).ready(function(){
    $(".send").click(function(){
    var name =  $("#name").val();
    var my_url= "https://api.instagram.com/v1/tags/"+name+"?access_token=2307573123.2c01fc8.d2a19d4145c84d59962c0db8d418d2a8";
    $("#name").val("");
    $.ajax({
        type: 'GET',
        url: my_url,
        dataType: 'jsonp'
    }).done(function(response){
            //response is our object with data
        }
        );
    });
});