What you actually need is to do whatever someFunc does inside the
success function. If it depends on the result of the ajax call, then
forget someFunc and someVar.

Why can't you just do it like this?
$.ajax({
          type: "GET",
          url: requestURL,
          success: function(msg){
                // do the thing someFunc does with someVar
         }
        });

On Jan 15, 8:26 am, Ilkinho <[EMAIL PROTECTED]> wrote:
> I have a small ajax issue here:
> function someFunc(){
> var someVar = true;
>
>         $.ajax({
>           type: "GET",
>           url: requestURL,
>           success: function(msg){
>                   ....
>          }
>         });
>
> }
>
> I have 2 problems:
> 1. I want someFunc to return a value according to the result of the ajax
> request - e.g. if msg is empty to return true, otherwise false. But if I
> attempt to return something, actually the function(msg) returns it somewhere
> and I don't get any result, which is logical since I'm inside an anonymous
> function like function(msg). So i try to assign this variable someVar and
> then return it like:
>
> url: requestURL,
> success: function(msg){
> someVar = false;
>
> }
> });
>
> return someVar;
>
> but it returns true... i suppose someVar is returned before the request is
> completed... so I don't know what to do? Any suggestions?
>
> --
> View this message in 
> context:http://www.nabble.com/simple-ajax-question-tp14833721s27240p14833721....
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to