2014-04-19 186 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