这是我的代码:
page.onResourceRequested = function (requestData, networkRequest) {
console.log(requestData.url); // This message shows http://website-with-jquery-included.com/page.html!
}
page.onResourceError = function(resourceError) {
console.log('Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')');
console.log('Error code: ' + resourceError.errorCode + '. Description: ' + resourceError.errorString);
};
page.open('http://website-with-jquery-included.com/', function(status) {
if (status === "success") {
page.evaluate(function() {
console.log('I can see this message');
$.ajax({url: 'http://website-with-jquery-included.com/page.html', success: function(resp) {
console.log('I cannot see this message!');
}});
});
}
});
函数page.onResourceError
输出错误消息:
无法加载资源 (#35URL:http://website-with-jquery-included.com/page.html)
错误代码:5。说明:取消操作
为什么取消了?我没有手动取消任何东西。它在浏览器(谷歌浏览器)中运行良好。