简体   繁体   中英

Looping over json results

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

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.

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

Try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM