2014-04-19 184 views
0

你好我每一個工作的應用程序,我需要解析json使用java腳本解析json。我google了很多,我幾乎從兩個3小時嘗試,但沒有得到任何正確的答案,我正在尋找。下面的代碼是我的嘗試。如何從url解析json?

我的代碼是:

<html> 
<head> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script> 
<script> 

$(function() { 

var entries = []; 
var dmJSON = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%27http%3A%2F%2Fcallme.myshareus.nl%2FAPI%2FgetGroups.php%3FAPIkey%3Dte7gRRT8Ut2VYW%26InitiatorId%3D0000001%26AccountId%3D00550%26Role%3D1%0A%27&format=json&diagnostics=true?callback=?"; 
$.getJSON(dmJSON, function(data) { 
    $.each(data.entity, function(i, f) { 
     var tblRow = "<tr>" + "<td>" + f.content + "</td>" + "</tr>" 
     $(tblRow).appendTo("#entrydata tbody"); 
}); 

}); 
}); 
</script> 
</head> 

<body> 

<div class="wrapper"> 
<div class="profile"> 
<table id= "entrydata" border="1"> 
<thead> 
     <th>ID</th> 
     <th>Name</th> 

    </thead> 
    <tbody> 

    </tbody> 
</table> 

</div> 
</div> 

</body> 

</html> 

我沒有得到任何性反應。

回答

0

在URL的結尾:

?callback=? 

應該是:

&callback=? 

在網址,?用於將參數從路徑分開,並&用於從單獨的參數彼此。

+0

謝謝先生回答我的問題,但我改變了&callback =?但仍沒有得到答覆。 – harshuli