Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.
This repository was archived by the owner on May 30, 2023. It is now read-only.

PhantomJS 2, not finished synchronous ajax request, while PhantomJS 1.9.8 finished it. #13891

@awakmu

Description

@awakmu

Hi,

I found that PhantomJS 2, not finished synchronous ajax request, but successfully run asynchronous one.
Using PhantomJS 1.9.8, both synchronous and asynchronous ajax request, run successfully.
This codes can be used to reproduce this issued:

var page = require('webpage').create();

page.onConsoleMessage = function(msg){
    console.log("console: " + msg);
};

page.onResourceRequested = function(requestData, networkRequest) {
    console.log('Request (#' + requestData.id + '): ' + JSON.stringify(requestData));
};

page.onResourceError = function(resourceError){
    console.log('ERROR: Unable to load resource (#' + resourceError.id + 'URL:' + resourceError.url + ')');
    console.log('ERROR: code ' + resourceError.errorCode + '. Description: ' + resourceError.errorString);
};

page.onResourceReceived = function(resource)
{
    console.log('Response '+ resource.stage +' (#' + resource.id + ', stage "' + resource.stage + '"): ' + JSON.stringify(resource));
};

page.open('http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first', function(status) {
    console.log('status: ' + status);
    page.evaluate(function(args)
    {
        var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
            if (xhttp.readyState == 4 && xhttp.status == 200) {
                console.log(xhttp.responseText);
            }
        };
        var async = false;
        xhttp.open("GET", "http://www.w3schools.com/ajax/ajax_info.txt", async);
        xhttp.send();
    });
});

Regards
-Awakmu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions