我正在开发一个 Web 应用程序,在该应用程序中我从反手调用 cgi-bin。我为此使用 ajax 请求。现在我想要一个场景,我想等到 cgi 响应到达。实际上,调用了一个表单操作也是cgi。现在我能够完成任务,但方法首先返回,稍后收到 cgi 响应。取决于 cgi 响应操作需要被调用。可能吗 ?请帮助...在此先感谢...这是我正在使用的代码:-
var flag = "";
if (xmlHttpReq.readyState == 0){
xmlHttpReq.open('POST', destinationURL, true);
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 4) {
if(xmlHttpReq.responseText == "OK"){
flag = true;
}
else{
flag = false;
}
}
}
xmlHttpReq.send();
}
return flag;
现在我只想在标志为 true 时调用表单操作,在 type =“submit”的按钮 onclick 事件中调用此函数。