you could make the ajax call synchronous so that javascript waits
until the request has been completed.
new Ajax.Request(targetXML, {
asynchronous: false,
onSuccess: function(transport) {
alert('in here')
quizJSON =
xml2json.parser(transport.responseText);
this.module = quizJSON.quiz.module;
this.unitTitle = quizJSON.quiz.unittitle;
this.unitNum = quizJSON.quiz.questions.count;
this.totalQuestions =
quizJSON.quiz.questions.count;
this.title = quizJSON.quiz.title;
},
onFailure: function() {
alert('Unable to load quiz data')
}
});
Alternatively, get the onSuccess method to call a method to perform
the output so that it happens after the XML is returned. I guess it
depends on what you are trying to achieve. If you want things to
happen in serial then the "asynchronous: false" should be fine.
Best Regards
Gareth