Hi I am using below jQuery.ajax call, in my onBeforeRendering() Method:
onBeforeRendering: function() {
jQuery.ajax({
url: "/prototype/OnlineQuestionnaire/getQuestionsAndResponseChoices.xsjs?questionnaireResponseId=" + escape(
questionnaireResponseId) + "&password=" + escape(
password),
// url: "/prototype/OnlineQuestionnaire/submitAndCreateQuestionnaire.xsjs",
method: "GET",
dataType: "json",
complete: this.onSuccess,
error: this.onErrorCall
});
console.log(output); //Gives undefined
}
onSuccess: function(jqXHR, textStatus) {
output = jqXHR.responseText;
output = JSON.parse(output);
console.log(output) //Gives me my JSON object from my response.
return;
},
Why does my console.log(output)
gives me undefined in my onBeforeRendering function ? I want to get the output result in my onBeforeRendering so that I can perform some validation here before rendering. At the moment I got a work around I perform my validations in the onSuccess function after I receive my output. But I want to do it after my ajax call in onBeforeRendering(). But I tried console.log(output) its undefined. How can access the output from my complete property of ajax call?