I am trying to display JSON data that I retrieve from an ajax call but I am unable to display any data despite getting the JSON object just fine.
<!DOCTYPE html>
<head>
<title></title>
<script src="jquery.js"></script>
</head>
<script>
$(document).ready(function(){
$.getJSON("http://servername:10000/_vti_bin/webservice/service1.svc/getListTitle",
{
username: "a",
password: "b",
list: "calendar",
},
function(data) {
alert(1);
// and the rest
}
)
});
</script>
<body>
</body
</html>
I don’t get any alerts but using Fiddler I can see the JSON object.
{"GetListTitleResult":"Calendar"}
So what am I missing here? Any help appreciated. Thanks in advance.
EDIT: It seems like the code doesn’t go all the way to the function(data) part. But firebug doesn’t show any syntax errors either. I still get the JSON response through Fiddler. Any help here?
Change your code this way –
In my opinion, these are the following mistakes that you’ve made –
dataitself will be a collection, you don’t need to getdata.items. Just pass thedataas is to theeachfunction.eachiterator will be passed thekeyand thevaluefor each item in the collection. Hence,iwill beGetListTitleResult, anditemwill beCalendar.