function JsonCall() {
JsonClient.setRequestHeader("Content-type", "application/json");
JsonClient.send(Data);
JsonClient.onload = function() {
SomeOtherFunction(this.responseText);
}
}
// This function is in someother class.
var Object = {
SomeOtherFunction: function() {
return data;
}
}
- What will my JsonCall function
return? - Can i do something where i can
return the value from onLoad call of
Json Object?
I want to do some logic in my other class and return the value via this JsonCall function
Looks odd to me. The
JsonClientobject is supposed to be aXHRobject here. However, aXHRobject offers aonreadystatechangeevent to handle a complete transfer by checking thereadyStateattribute.The only exception is a
XDomainRequestobject from the Internet Explorer. That object indeed has an.onloadproperty. Right now, yourJsonCall()methods returnsundefined. You would need to add acallback methodto execute. Likeand then call it like
where I hope
Objectis just an example word here.