I have a really simple chat application on a site which works pretty good.
It requests by ajax like this:
$.ajax({
url: "fetch/"+CHAT_SESSION_ID+"/"+LAST_MESSAGE_ID,
dataType: "json",
cache: false,
success: function(data) {
if (data.session_active == 0) { //If other chatter ended session
alert("Session Ended");
}
else
{
$.each(data.messages, function(i,msg){
alert(msg.message.Body);
)};
}
}
});
and gets a json response that lookes like this:
{ "session_active": "1", "messages": [ {"message": {"MsgID": "100", "UserID": "1", "Body": "heyy"}}, ]}
It works really well in at least FF and Saf but in Chrome it never gets past the .each!
This is driving me nuts, have tried everything I’ve come across online for days but I can’t seem to get it right.
Please someone help! I can provide testserver if someone wants to firebug it themselves 😉
Perhaps the trailing comma in your messages array is causing an issue. See the responses to the following question:
Can you use a trailing comma in a JSON object?