···js var optionsForm = { url: ‘https://myportal.vtc.edu.hk’+$(‘form’).attr(‘action’), body: ‘userid=140154313&password=159197ck@&ajaxLogin=true’ }; request.post(optionsForm, function (mErr, httpResponse, mbody) { console.log(httpResponse.statusCode); debugger; if (mErr) { return console.error(‘ERROR:’, mErr); } if(mbody){ var $ = cheerio.load(mbody); var TimeData = $(’#hkvtcsp_menu’).children(‘span’).eq(2).find(‘a’); res.end(JSON.stringify({‘Html’:$(‘title’).text(), cookies: httpResponse.headers[‘set-cookie’]})); }else{ res.end(JSON.stringify({url:’’, title: ‘’})); } });
我想实现 能抓取到类似$.ajax.complete 里的 XMR 数据
请问怎么实现好?
下面是一个jquery 的前端例子, 主要就是判断并拿出 jqXHR.responseText
```js
$.ajax({
url: loginForm.attr('action'),
cache: false,
async: false,
data: params,
type: "POST",
complete: function(jqXHR, textStatus) {
if (jqXHR.status == 200) {
// login successfull
window.location = '/wps/myportal';
} else if (jqXHR.status == 399) {
// login successfull
window.location = jqXHR.responseText;
} else if (jqXHR.status == 398) {
// need retry login due to existing session
GoLogin();
} else {
loginForm.find('input[name="password"]').val('');
loginForm.find("#btn").removeClass("btn_loading");
loginForm.find("input").filter(':submit').removeAttr('disabled');
if (jqXHR.status == 396){
alert('Your record is not found yet, please login by next day after your registration.');
} else {
cnaStatus(loginForm.find('input[name="userid"]').val());
}
}
}
});