How to get this JavaScript class member to return a value?
Posted
by George Edison
on Stack Overflow
See other posts from Stack Overflow
or by George Edison
Published on 2010-05-30T03:15:42Z
Indexed on
2010/05/30
3:22 UTC
Read the original article
Hit count: 214
I have a JavaScript class that has a method:
function someClass() {
this.someMethod = someClass_someMethod;
}
function someClass_someMethod() {
// make an AJAX request
}
The problem is that someClass_someMethod()
needs to return the value of the AJAX request.
I'm using jQuery's $.getJSON()
method to fetch the data. The data needs to be returned but it seems the only way to get the data is through a callback.
How can this be done?
© Stack Overflow or respective owner