The second option - calling another function from the callback - is really the way to go. Otherwise you don't know when the data is ready. By calling the other function from the callback, you can ensure that the data is actually present.
-Mike > From: ricardobeat > > just declare the variable outside the callback, in the scope > where you need it, for example: > > $('something').click(function(){ > > var message; //the var 'message' will be available > inside this function, and can be set by any inner function > > $.getJSON('http://...', function(data){ > message = data; > }); > > }); > > You can also call another function inside your callback, passing the > data: > > function getData(data) { doSomethingWithIt } > > $.getJSON('http//...', getData) //the 'data' parameter will > be passed to it on execution > > About scope and closures in JS: > http://www.robertnyman.com/2008/10/09/explaining-javascript-sc > ope-and-closures/ > http://odetocode.com/Blogs/scott/archive/2007/07/09/11077.aspx > > - ricardo > On Dec 5, 11:33 am, "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > > I spek in Englisn bed. Sorry. Part of sample code: > > > > $.getJSON("http://some.url/?callback=?" > > function(json){ > > var result = json.error; > > var message = json.message; > > var record = json.data; > > }); > > > > How I return value of the variable: result or message or record to > > others part of script? it is possible? >