除了提交 HTML 表单之外,是否可以通过其他方式处理 XWiki 上的请求?我需要使用 XMLHttpRequest,但$request
根本不响应请求。
JavaScript 代码
function requestHandle(msg, subj) {
var recipientName = recipientsArr.pop()[0];
req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
console.log('req ok');
var mailStatusTmp = "<div class=\"mailStatus\">" + recipientName + " <span class=\"glyphicon glyphicon-ok\"/></div>";
$('#mailStatusWrapper').append(mailStatusTmp);
if (recipientsArr.length > 0) {
requestHandle(msg, subj); // call requestHandle() for next recipient
} else {
return;
}
} else {
console.log('req err');
var mailStatusTmp = "<div class=\"mailStatus\">" + recipientName + " <span class=\"glyphicon glyphicon-remove\"/></div>";
$('#mailStatusWrapper').append(mailStatusTmp);
if (recipientsArr.length > 0) {
requestHandle(msg, subj); // call requestHandle() for next recipient
} else {
return;
}
}
}
};
req.open("POST", "https://wiki.intra.tieto.com/xwiki/bin/view/Sandbox/TestPage1", true);
req.send("msg=" + msg + "&subj=" + subj + "&recipientName=" + recipientName);
}
我想使用 XMLHttpRequest,因为页面会将数据发送到多个接收者,我需要检查每个请求的状态。