Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
151 views
in Technique[技术] by (71.8m points)

javascript - I want to fetch data from a specific URL , after that i want to grab specific dom element.But given null response

I am trying to fetch HTML of a specific ULR. I want to grab specific class from there .

This is the full code.

(function () {
    try {
      /*-----------------------
      section data 
    -----------------------*/
      var FeHelper = this;
      //wait for element to load
      FeHelper.doWhenElementLoaded = function (
        selector,
        trigger,
        delayInterval,
        delayTimeout
      ) {
        var interval = setInterval(function () {
          if (
            document &&
            document.querySelectorAll(selector) &&
            document.querySelectorAll(selector).length > 0
          ) {
            clearInterval(interval);
            trigger();
          }
        }, delayInterval);
        setTimeout(function () {
          clearInterval(interval);
        }, delayTimeout);
      };
      /*-----------------------
      init is the main controller
      --------------------*/

      FeHelper.solve = function(data){
          console.log(data);
          console.log(data.querySelector(".twitter-cards.slick-initialized.slick-slider"));
      }

      FeHelper.init = function () {

        var xhr = new XMLHttpRequest();
        xhr.onload = function() {
          FeHelper.solve(this.responseXML);
        }
        xhr.open('GET', 'https://www.generationgenius.com/about/', true);
        xhr.responseType = "document";
        xhr.send();
      };
      FeHelper.doWhenElementLoaded('body', FeHelper.init, 50, 10000);
    } catch (err) {
      // console && console.log(err);
    }
  })();
question from:https://stackoverflow.com/questions/65838087/i-want-to-fetch-data-from-a-specific-url-after-that-i-want-to-grab-specific-do

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...