I have a unique challenge: While on URL1(random wikipedia page), make an ajax request to URL2(100 most common words wikipedia page), create array from returned data to be used later.
I have to run this from the console while on "URL1" example:
- Navigate to URL1
- Open Console
- paste code
- hit enter
So far I have been able to get very close with the following:
$.ajax({
url: 'https://en.wikipedia.org/wiki/Most_common_words_in_English',
type: 'GET',
dataType: 'html',
success: function(data) {
Names = $.map($(data).find('.wikitable tr'), function() {
return $(this).find('td:last').text()});
console.log(Names);
}
});
But I'm getting blank values in my array.
While on URL2(link in the ajax request) the following code works perfect
var Names = $('.wikitable tr').map(function() {
return $(this).find('td:last').text() }).get(); console.log(Names);
I was gettin errors using this exact code because of the .get, after removing it, I got an array with the proper amount of elements, but they were all blank.
Thanks