我正在嘗試使用Google Apps腳本訪問POST請求的參數。我可以使用e.parameter記錄params對象,儘管我似乎無法通過使用e.parameter.name來訪問對象的鍵。訪問XMLHttpRequest中的參數Google Apps腳本
的XMLHttpRequest
var http = new XMLHttpRequest();
var url = "myappURL";
var params = JSON.stringify({employeeStatus: "Active", name: "Henry"});
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//Call a function when the state changes.
http.onreadystatechange = function() {
// call back function
} // end callback
http.send(params);
谷歌Apps腳本
function doPost(e) {
if (typeof e !== 'undefined') {
Logger.log(e.parameter.name); // does not work (undefined)
} // end if
} // end doPost
也許你可以分享一個公共版本的腳本來看看嗎? – Sudsy
@Sudsy [link](https://script.google.com/d/1MxBNwUoG4I_F0Gt1GGYzNrr3m6PakhcDFxIA_g-nvoS-bRHx0IS5jgMJ/edit?usp=sharing) –