[jQuery] Re: problem with $.JSON request

2008-12-08 Thread botondus
A possible (but not the most efficient) solution would be something like this: function getAllWhatever() { var result = this.getAllRecords(); var record = new Array(); var test = 13; alert(test); while(result.isValidRow()) { record = someN

[jQuery] Re: problem with $.JSON request

2008-12-08 Thread botondus
The first example ricardo gave you is not ok. Use the second example. Because "http://test.url/?callback=?";, gets called, but javascript doesn't wait to get a response from that request (the first A from AJAX is from Asynchronous!). It goes forward and calls it again and again and again quickly w

[jQuery] Re: problem with $.JSON request

2008-12-08 Thread suhinin.dmit...@gmail.com
For example: function someName() { var result = this.getAllRecords(); var data = new Array(); var test = 13; alert(test); while(result.isValidRow()) { $.getJSON("http://test.url/?callback=?";, { TABLE_NAME:'BARCODE_CODES', RECORD_ID: res

[jQuery] Re: problem with $.JSON request

2008-12-05 Thread Michael Geary
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

[jQuery] Re: problem with $.JSON request

2008-12-05 Thread 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){ me