2015-09-28 63 views
-2

我想拉從這個JSON文件數據(標題,作者等):在Javascript/jQuery的 http://www.nba.com/grizzlies/api/v1/json解析JSON供稿網頁

我怎麼會去嗎? 我似乎無法做到。

+1

該網址未啓用CORS。另外,當詢問你如何發佈代碼時,你已經嘗試過......這不是一種代碼編寫服務......人們用你寫的代碼來幫助你 – charlietfl

+0

[這是JSONP](http://www.nba) .com/grizzlies/api/v1/json?callback = parsejson)啓用。 – Andy

+0

我會研究JSONP,但我已經嘗試了一些來自本教程的內容:http://beautifulbeta.wikidot.com/json-feeds – hellothere

回答

0
$.ajax({ 
    type: 'GET', 
    url: "http://www.nba.com/grizzlies/api/v1/json", 
    dataType: "jsonp", 
    success: function (data) { 
     console.log(data); 
     $.each(data, function (index, value) { 
      $.each(value, function (idx, val) { 
       console.log(val.author); 


      }) 


     }) 

    }, 
    error: function (data) { 

    } 
}); 

如果你想嘗試下面的演示。

Demo

+0

謝謝,這是一個好的開始。 – hellothere

+0

很高興它幫助快樂的編碼 – guradio