I did look out for some other answers on SO in regards, and from one of them I found the one I am using on here, yet it looks like it's never happening as this isn't firing return false;
neither the console.log(myId);
which normally should.
let pattern = new RegExp('^\/wiki\/');
var total = doSelect("Location").siblings('td').find('a').length;
doSelect("Location").siblings('td').find('a').each(function(i, el, index) {
var result = $(this).attr('href').replace(pattern, '');
console.log(result);
if (index === total - 1) {
myId = item.pageid;
console.log(myId);
return false;
}
});
I even tried the following as suggested on this other SO answer with no positive results:
let pattern = new RegExp('^\/wiki\/');
doSelect("Location").siblings('td').find('a').each(function(i, el) {
var result = $(this).attr('href').replace(pattern, '');
console.log(result);
}).promise().done( function(){
myId = item.pageid;
console.log(myId);
return false;
});
UPDATE
About: item
(no issue with the following data), the above code is within the following data each
:
$.getJSON(url,function(data){
$.each(data, function(i, item) {