Curious behaviour with JavaScript

I was messing around with JavaScript prompts (based on an example by Pertex), and discovered something rather odd. Here is the script:

    <start type="script">
question = "What is your name?"
default = "Anonymous"
request (RunScript, "jsinputbox;"+ question +";"+default + ";NameOutput")
on ready {
question = "How old are you?"
default = "0"
request (RunScript, "jsinputbox;"+ question +";"+default + ";AgeOutput")
}
</start>


What is strange is that the player is asked his age first, and then his name, despite the on ready command.

File:

Struggling to upload the JavaScripot file, so this is the content:

function jsinputbox(question, def, callback) {
var answer = prompt(question, def);
ASLEvent(callback, answer);
}

"on ready" fires when there are no outstanding ASL callbacks - things like "wait", "ask" etc. It doesn't know anything about what's happening in Javascript-land, so it will trigger immediately in your example.

If you want to fire some ASL after the Javascript, use ASLEvent (as you are currently doing) to ask the second question. Then there will only be one Javascript prompt at a time.

So why do they fire in reverse order?

I don't know, maybe the later one appears in front of the first one?

No, the first window does not appear until you dismiss the second one.