I have the following and I am trying to figure out how to search the array of objects - the call() function is called multiple times ?
var arr = [];
var newData;
function call() {
newData = $('a').attr('href');
if($.inArray(newData, arr) == -1) {
$.post('/blah', function(data) {
arr.push(data);
});
}
}
data is like [object{ }] so arr becomes [[object{id='1', myUrl=''}], [object{id='2', myUrl='' }]].
What I am trying to figure is out whether newData is contained within the arr ?
arr = []and without populating it, you are trying to search$.inArray(newData, arr)which I think will always return you -1newDataexists in thearr- that is, whether it's one of themyUrl?