PhantomJS: Operation Canceled while loading resource via AJAX
Asked Answered
R

0

9

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!');
            }});
        });
    }
});

Function page.onResourceError prints the 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 didn't cancel anything manually. It works well from the browser (Google Chrome).

Rosser answered 6/3, 2016 at 19:50 Comment(5)
Try adding error callback into your ajax call and analyze error message.Unlovely
It gives Operation canceledRosser
Is that your complete code? Where is your phantom.exit(); line?Okay
Were you able to solve this problem? I am also having the same problem and pulling out my hair now!Heal
i have the same problem. Did someone solve it yet?Tobacco

© 2022 - 2024 — McMap. All rights reserved.