最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - XMLHTTPRequest is not defined? Google Spreadsheets? - Stack Overflow

programmeradmin1浏览0评论

I'm fairly new to Ajax and was working on some scripts in Google Spreadsheets and was given the error: "ReferenceError: "XMLHttpRequest" is not defined. (line 21, file "getBookmarks")". Is there a problem with my code or is it that certain functions are limited when making a XMLHtppRequest in Google Spreadsheets to an external source?... I checked and all the other functions I used were fine?

function getBookmarks() {
   //Opening Active Spreadsheet
   var ss = SpreadsheetApp.getActiveSpreadsheet();
   var sheet = ss.getSheets()[0];

    // Get the range of cells that stores event data.
    var eventDataRange = ss.getRangeByName("Url");

    // Stores URL into eventObject
    var eventObject = getRowsData(sheet, eventDataRange);

     for (var i=0; i < countProperties(eventObject); i++)
    {

     //Making the Ajax Call

      var xmlhttp;
      xmlhttp=new XMLHttpRequest();
      xmlhttp.open("GET",eventObject[i],true);
    }
   //search for string ""global-bookmark-count" class="count-text">"
   //get bookmark number bookmark
   //return bookmark //returning bookmark count 
  }

I'm fairly new to Ajax and was working on some scripts in Google Spreadsheets and was given the error: "ReferenceError: "XMLHttpRequest" is not defined. (line 21, file "getBookmarks")". Is there a problem with my code or is it that certain functions are limited when making a XMLHtppRequest in Google Spreadsheets to an external source?... I checked and all the other functions I used were fine?

function getBookmarks() {
   //Opening Active Spreadsheet
   var ss = SpreadsheetApp.getActiveSpreadsheet();
   var sheet = ss.getSheets()[0];

    // Get the range of cells that stores event data.
    var eventDataRange = ss.getRangeByName("Url");

    // Stores URL into eventObject
    var eventObject = getRowsData(sheet, eventDataRange);

     for (var i=0; i < countProperties(eventObject); i++)
    {

     //Making the Ajax Call

      var xmlhttp;
      xmlhttp=new XMLHttpRequest();
      xmlhttp.open("GET",eventObject[i],true);
    }
   //search for string ""global-bookmark-count" class="count-text">"
   //get bookmark number bookmark
   //return bookmark //returning bookmark count 
  }
Share Improve this question edited Sep 9, 2013 at 2:53 Mogsdad 45.8k21 gold badges162 silver badges285 bronze badges asked Jul 12, 2013 at 19:05 user2577475user2577475 1712 gold badges2 silver badges6 bronze badges 1
  • Does this answer your question? Ajax calls made from Google Spreadsheet Custom Function – Christoph Rackwitz Commented Jan 21, 2024 at 22:46
Add a ment  | 

1 Answer 1

Reset to default 4

Google Apps Script does not support that function, see this answer for guidance.

发布评论

评论列表(0)

  1. 暂无评论