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
$.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 =
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
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 something
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 test()
after $.get work strange
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
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 ret;
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 it
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
9 matches
Mail list logo