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 like that:
function isTracked(...)
{
$.get('istracked.php',...);
return value_from_istrackedphp
}
//and then
if (isTracked(...)=='true')
//thing A
else
//thing B
---
> var r;
>
> function isTracked(personcode, callback) {
> $.get('trackstudent/istracked.php',{'personcode': personcode},
> callback);
> }
>
> $(document).ready(function() {
>
> isTracked('10591891',function(data) {
> r=data;
> alert(r);
> });
>
> });
So in that case I dont have to use callback in isTracked.
I can do the same thing in this way:
function isTracked(personcode) {
$.get('trackstudent/istracked.php',{'personcode': personcode},
function(data) {
r=data;
alert(r);
});
}
and i still will have alert with proper value, but its not what I
want.
I want to get data from php file and return it from isTracked
function. ( to do something like that: ...
if (isTrackes(..)=='true'))
Thanks
Michael