Jquery JSON .each() doesnt work in Google Chrome

Posted by Sheriffen on Stack Overflow See other posts from Stack Overflow or by Sheriffen
Published on 2010-05-12T16:31:00Z Indexed on 2010/05/12 16:34 UTC
Read the original article Hit count: 186

Filed under:
|
|
|
|

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

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JSON