weixin_33695082 2016-04-15 05:57 采纳率: 0%
浏览 87


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:

  1. Navigate to URL1
  2. Open Console
  3. paste code
  4. hit enter

So far I have been able to get very close with the following:

    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()});

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.


  • 写回答



      相关推荐 更多相似问题


      • ¥30 如何降低hdfs中datanode的JVM内存用量
      • ¥15 Android URL如何转成视频/音频,可行吗?
      • ¥20 SQL数据查询,子查询
      • ¥15 c++字符串分割问题
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver