In JQuery, how to loop through AJAX response that isn't key/value pair. When output response to div, it looks like:
[true,false, true, true,...]
I cannot figure out how to access each element to check the Boolean value.
In JQuery, how to loop through AJAX response that isn't key/value pair. When output response to div, it looks like:
[true,false, true, true,...]
I cannot figure out how to access each element to check the Boolean value.
You don't need jQuery to loop on a simple array.
You could do a simple JavaScript for
loop like:
for (var i=0; i < [true, false, ...].length; i++){
// Do stuff with i here...
}
If you wanted to use jQuery though, there is a method each
(see docs) that you could use like this:
$.each([true, false, ...], function(index, value){
// Do stuff with value here...
});