I have an Ajax call that returns an array and need to do something with each of the values from this array.
So far I have the below but this returns the following error:
Uncaught TypeError: Cannot use 'in' operator to search for 'length' in array(5)...
Can someone tell me what I am doing wrong here resp. how I can do something with each of the values ?
My Ajax:
$.ajax({
type: "post",
url: "ajax.php",
cache: "false",
data: {
node: 'fetchValues',
itemIDs: itemIDs
},
success: function(data){
console.log(data); // for testing only
jQuery.each(data, function(index, value){
console.log(value);
});
}
});
Example for "data" (from console log):
array(5) {
[1]=>
string(6) "Value1"
[2]=>
string(6) "Value2"
[3]=>
string(6) "Value3"
[4]=>
string(6) "Value4"
[5]=>
string(6) "Value5"
}
Many thanks in advance for any help.