Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON Iteration - My JSON object is being treated as a string literal?

This is probably a super easy question but I'm banging my head on it for some reason.

Here is the jQuery I have

$(function() {
    $.get(urlGetContainerNumbers, function(data) {
        console.log(data);

        for (var idx = 0; idx < data.length; idx++) {
            var containerNo = data[idx];
            console.log(containerNo);
        }
    });
});

This is what is produced in firebug

JSON Iteration

I am expecting that when iterating through data I would get 1001, 1002, 1003, 1004, etc.

What am I overlooking? It seems as though the for loop isn't treating data as a json object, but rather a string literal...

like image 310
Jon Erickson Avatar asked Nov 26 '25 23:11

Jon Erickson


1 Answers

Methinks you mean $.getJSON rather than $.get.

like image 148
chaos Avatar answered Nov 28 '25 12:11

chaos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!