Ajax - XMLHttpRequest in Oolite

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Day
---- E L I T E ----
---- E L I T E ----
Posts: 518
Joined: Tue Mar 03, 2015 11:35 am
Location: Paris

Ajax - XMLHttpRequest in Oolite

Post by Day » Mon Mar 04, 2019 11:27 am

Hi everybody,

I'm trying to make an XMLHttpRequest in an OXP world script.

I got an error:

Code: Select all

var req = new XMLHttpRequest();
req.open('GET', 'http://www.mozilla.org/', false);
req.send(null);
if (req.status === 200) {
    log("smthg","answer received: "+ req.responseText);
} else {
    log("smthg","status of the reply: "+ req.status+" "+req.statusText);
}

Code: Select all

10:50:44.700 [script.javaScript.exception.notDefined]: ***** JavaScript exception (DayDiplomacy_090_Sqlite): ReferenceError: XMLHttpRequest is not defined
Would it be that XMLHttpRequest is not compiled into Oolite?
Is there a solution?

I have seen in the embedded mozilla code regression tests that XMLHttpRequest is used. But maybe these regression tests are dead code?

Every hint is welcome :-)

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 5394
Joined: Wed Feb 28, 2007 7:54 am

Re: Ajax - XMLHttpRequest in Oolite

Post by another_commander » Mon Mar 04, 2019 1:01 pm

From this link at Mozilla Developer Network:
The word JavaScript may bring to mind features such as event handlers (like onclick), DOM objects, window.open, and XMLHttpRequest. But in Mozilla, all of these features are actually provided by other components, not the SpiderMonkey engine itself.
Sorry, it will not work.

User avatar
Day
---- E L I T E ----
---- E L I T E ----
Posts: 518
Joined: Tue Mar 03, 2015 11:35 am
Location: Paris

Re: Ajax - XMLHttpRequest in Oolite

Post by Day » Mon Mar 04, 2019 3:32 pm

Thank you another_commander, I hadn't found this :-)

I will find another way :wink:

Post Reply