1
我試圖與服務器comunicate,使用JavaScript中的XMLHttpRequest。傳遞額外的參數給XMLHttpRequest.onload
如何傳遞到onload事件功能的信息?
// global variable that containts server response
var reply;
var makeRequest = function(extraInfo) {
var request = new XMLHttpRequest();
request.open(...);
request.onload = handler;
};
var handler = function(data) {
reply = data.target.response;
console.log("Server Reply: " + reply);
};
如何將參數extraInfo從makeRequest傳遞到處理函數? (不使用全局變量)