AJAX 响应完成后如何触发函数?
在更改下拉菜单时,manageImagesDynamicObjectDetails
调用该函数:
<select id="imageComponentSelection" name="imageComponentSelection" onchange="manageImagesDynamicObjectDetails()">
此函数将与此 AJAX 调用相关的变量传递给我的makeRequests
函数。
function manageImagesDynamicObjectDetails(){
var sendContent = "selection=".concat(document.getElementById('imageComponentSelection').value);
var fileName = "RetrieveObjectsInformation";
var elementId = "objectData";
if(sendContent != "Select a class to view components"){
makeRequest(fileName,sendContent,elementId);
}
}
makeRequest
是一个函数,它将为所有 AJAX 调用调用并适当地处理它们。
function makeRequest(fileName,sendContent,elementId) {
var xmlHttpRequest = getXMLHttpRequest();
xmlHttpRequest.onreadystatechange = getReadyStateHandler(xmlHttpRequest,elementId);
xmlHttpRequest.open("POST", fileName, true);
xmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttpRequest.send(sendContent);
}
当特定的 AJAX 调用完成后,我想调用 resizeObjectList 函数。
function resizeObjectList(){
var windowHeight = $('#contentWrapper').height();
var newObjectListHeight = windowHeight - 53 - 20 - 20 - 60;
var element = document.getElementById("componentObjectList");
if (typeof(element) != 'undefined' && element != null){
document.getElementById("componentObjectList").style.height = newObjectListHeight;
}
}
我该怎么做呢?我试过了ajaxComplete
,ajaxStop
但我无法让它们触发。