I call a RESTAPI which returns a json encoded array.
When I open the API URl directly in browser it returns
the correct number of elements - no repetition, but
on calling the API in a script and using Javascript to loop
through the returned array, the elements are printed out twice,
it's like the loop the loop runs twice, I've checked and checked
but don't know why.
Now,I'm trying to loop through the array and not print out an element
if it is already printed with a script like this, but it doesn't seem to
work, how do I re-write the script.
<script>
var holdit = [];
$.each(myArray, function(key, value) {
if($.inArray(key, holdit)) == -1;
{
alert( "The key is '" + key + "' and the value is '" + value + "'" );
holdit.push(key);
}
});
</script>