sevenkul
sevenkul

Reputation: 966

Codes inside .getJSON() function doesn't fire

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");
});

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

Answers (1)

Grumsh
Grumsh

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

Related Questions