0

Good day! How can i access the msg -> items with jQuery .each()?

{
            "msg": [
                {
                    "msg_id": "18628",
                    "msg_userid": "12",
                    "msg_username": "Jordan",
                    "msg_type": "msg",
                    "msg_text": "example",
                    "msg_w_to": "0",
                    "msg_created": "03:49:11"
                },
                {
                    "msg_id": "18629",
                    "msg_userid": "12",
                    "msg_username": "Jordan",
                    "msg_type": "msg",
                    "msg_text": "example",
                    "msg_w_to": "0",
                    "msg_created": "03:49:44"
                },
                    {
                    "msg_id": "18936",
                    "msg_userid": "25",
                    "msg_username": "Jack",
                    "msg_type": "msg",
                    "msg_text": "example",
                    "msg_w_to": "0",
                    "msg_created": "23:21:08"
                }
            ],
            "isNew": 0,
            "playSound": 1,
            "lastmsg_from": "Jack",
            "error": "0",
            "append": 0,
            "last_id": "18936",
            "me_username": "Morten"
        }

I've searched and tested for hours now but won't work. Anyone who could help me out? Thank you in advance! - M

1 Answers1

0

You are not looping through the array, you are looping through the object.

$.each($.parseJSON(data).msg, function(index, value) {
epascarello
  • 204,599
  • 20
  • 195
  • 236