[jQuery] Re: functions after $.get work strange

2007-09-28 Thread [EMAIL PROTECTED]
> Erik Beeson wrote: > The value from $.get CAN NOT be returned from isTracked because isTracked will > have returned before the $.get callback executes. Shame :/ But thank you for that answer. I was fighting because I thought that it is possible. Waste of time :/ So I have no choice and put all

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Michael Geary
> Michael Geary wrote: > > You're still expecting things to happen in the wrong order. > > It's *inside the callback* that the data becomes available, > > and this is long after isTracked() returns. > From: [EMAIL PROTECTED] > Yes, but I want have a function that will return what i get from > i

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Erik Beeson
As I said to you offlist, it doesn't work that way. The value from $.get CAN NOT be returned from isTracked because isTracked will have returned before the $.get callback executes. Instead of: if(isTracked(code) == 'true') { // thing A } else { //thing B } You have to do: isTracked(code, fun

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread [EMAIL PROTECTED]
Michael Geary wrote: > You're still expecting things to happen in the wrong order. It's *inside the > callback* that the data becomes available, and this is > long after isTracked() returns. Try this instead: Yes, but I want have a function that will return what i get from istracked.php to use

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread [EMAIL PROTECTED]
> To answer your specific question, setting > a variable who's scope is outside the callback is as easy as defining the > variable outside the callback: > > var foo; > $.get(..., function() { foo = ...; }); Ahh, I know know where was my mistake. I tried something like that: function a() { var r

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Michael Geary
007 7:01 AM > To: jQuery (English) > Subject: [jQuery] Re: functions after $.get work strange > > > > function isTracked(personcode, callback) { > > $.get('trackstudent/istracked.php', {'personcode': personcode}, > > callback); > > > > }

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread [EMAIL PROTECTED]
First of all - Thank You very much - it is good lesson. > To answer your specific question, setting > a variable who's scope is outside the callback is as easy as defining the > variable outside the callback: > > var foo; > $.get(..., function() { foo = ...; }); I tried that before: function te

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread [EMAIL PROTECTED]
> function isTracked(personcode, callback) { > $.get('trackstudent/istracked.php', {'personcode': personcode}, callback); > > } > > isTracked(code, function(tracked) { > // do something with tracked, exactly as you would have done above. > > }); I thought that I understand that but Im doing s

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Guy Fraser
Erik Beeson wrote: > $.get is asynchronous, meaning the call to $.get returns immediately, > even before the callback has happened. To answer your specific > question, setting a variable who's scope is outside the callback is as > easy as defining the variable outside the callback: Erik - your

[jQuery] Re: functions after $.get work strange

2007-09-27 Thread Erik Beeson
$.get is asynchronous, meaning the call to $.get returns immediately, even before the callback has happened. To answer your specific question, setting a variable who's scope is outside the callback is as easy as defining the variable outside the callback: var foo; $.get(..., function() { foo = ...