Ajax calls made from Google Spreadsheet Custom Function

非 Y 不嫁゛ 提交于 2019-12-22 04:56:31

问题


Hey guys have anyone of you ever tried to write a script inside a Google Spreadsheet to make an ajax call to a website. I want to make it so that the spreadsheet updates itself from the website. But after just putting this short block of code, I get thrown an error: "ReferenceError: "XMLHttpRequest" is not defined." Any help guys? Do I have to call a certain library?

xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET", eventObject[1], true);
xmlhttp.send();

回答1:


Google Apps Script does not support XMLHttpRequest() natively, but as you suspected there are services that can accomplish the same thing.

Look at UrlFetch Services, Class Xml (deprecated) and Xml Services.

One of the apps script tutorials (Accessing Picasa Web Albums through Apps Script) covers the use of these services, and would be a good place for you to start.



来源:https://stackoverflow.com/questions/18021422/ajax-calls-made-from-google-spreadsheet-custom-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!