Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax calls made from Google Spreadsheet Custom Function

Has anyone 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 idea? Do I have to call a certain library?

xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET", eventObject[1], true);
xmlhttp.send();
like image 736
user2577475 Avatar asked Aug 02 '13 16:08

user2577475


1 Answers

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.

like image 165
Mogsdad Avatar answered Sep 23 '22 02:09

Mogsdad