To simplify my question i did some modifications to the code. I am now able to get the value from the callback function i now want to pass this data into a variable.
Javascript
How can i get PostInformation to return args?
function AjaxRequest(callback) {
var hasErrors = false;
dojo.xhrPost({
url: 'hello',
content: SomeData,
load: function (formErrors) {
//preform some operation
//set hasErrors to true
hasErrors = true;
if (typeof callback === "function") callback(hasErrors);
},
error: function (e) {
console.log(e + ' page not posted error');
}
});
}
function PostInformation() {
try {
AjaxRequest(function (args) {
console.log('The hasErrors is ' + args);
return args;
});
} catch (e) {
console.log(e);
}
}