This is my code:
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!'); }}); }); } });
The page.onResourceError function displays an error message:
Unable to load resource (# 35URL: http://website-with-jquery-included.com/page.html )
Error code: 5. Description: Operation canceled
Why is it canceled? I did not cancel anything manually. It works well in a browser (Google Chrome).
ajax asynchronous phantomjs jquery-callback
Serhii Matrunchyk
source share