0

I have the following json results being returned to me and I can't work out how to loop over the success results. Here is an example of what is being returned

{"ERRORS":[],"SUCCESS":["7336","7337","7356"]}

This is where I have got to so far but it's not working

jQuery.each( data.success, function( i, val ) {
   console.log(val);
});

Any help would be appreciated

2
  • 8
    data.SUCCESS instead of data.success Commented Dec 10, 2013 at 15:32
  • 2
    javacsript is case sensitive Commented Dec 10, 2013 at 15:34

2 Answers 2

3

Make success same case.

jQuery.each( data.SUCCESS, function( i, val ) {
   console.log(val);
});

JavaScript is case sensitive. I would recommend using lower case letters (camelCase) when working with json - but it's a matter of preference of course.

Sign up to request clarification or add additional context in comments.

Comments

-1

You don't need the parameter passing when using jQuery.each.

Try this:

jQuery.each(data.SUCCESS, function() {
   console.log(this);
});

2 Comments

Well, it's still represents the same value.
Yes, as Johan said, it makes no difference. The correct part of your answer is the data.SUCCESS part.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.