I'm not sure what you're trying to achieve here since, by definition,
you won't be able to return a value from an asynchronous interaction.

The closest you could get would be to do:

function test(){
  var ret;

     $.ajax({
        type: "POST",
        url:"/ajax/test/",
        data: { ...]
        dataType: "json",
        success: function(data){
           ret = true;
        }
     });
  }

  return ret;
}

But even that won't work because ret will be undefined if the behavior
is asynchronous. Changing to synchronous (adding async: false) would
make the above work.

--John

On Wed, Oct 22, 2008 at 4:24 AM, bucheron <[EMAIL PROTECTED]> wrote:
>
> Hi everyone,
>
> here is my problem:
> I would like to get a return value of test() given by the callback
> function.
> The problem I have is because the scope of the callback doesn't
> interact with the test function so I'm not able to interact between
> them.
>
> here is my function:
>
> Code:
> function test(){
>      $.ajax({
>         type: "POST",
>         url:"/ajax/test/",
>         data: { ...]
>         dataType: "json",
>         success: function(data){
>            return true;
>
>         }
>      });
>   }
> }
>
>
> How would be possible to get the return value of the callback function
> in test() function in order to make something like:
>
> Code:
> function test(){
>      return $.ajax({
>         type: "POST",
>         url:"/ajax/test/",
>         data: { ...}
>         dataType: "json",
>         success: function(data){
>            return true;
>
>         }
>      });
>   }
> }
>
>
> In advance thanks
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to