Reputation: 966
There lots of questions about getJSON but I couldn't find an answer to my problem. I have this simple code:
$.getJSON("ashx/GetVote.ashx?id=" + recordID, function (data) {
$("#kg-VoteAvg-" + recordID).html(data.VoteAvg);
$("#kg-VoteCount-" + recordID).html(data.VoteCount);
alert("sth");
});
{VoteAvg:'1', VoteCount:'1'}
$("#kg-VoteAvg-" + 2).html(1);
works.However, my code lines inside the function neither fires nor gives an error. Where do am I doing wrong? I can use .ajax() function but wondering why my alert or others in .getJSON() function doesn't work.
Upvotes: 0
Views: 519
Reputation: 139
The JSON is not valid, you need to return
{"VoteAvg":1, "VoteCount":1}
http://json.org/ stipulates that JSON structures need to enclose their keys in double quotes.
Upvotes: 4