0

Guys!

I have a one misunderstanding in javascript. I want make a ajax-request with function foo() and i want return result data by foo() return, but i can't return something in callback function in $.ajax.

So i want this: if ajax reurn data then function foo() return same data.

function foo(){
    $.ajax({
        url: "test.html",
        param: {} 
     }).done(function(data) {
          //I need return data variable how result of function foo() running            
     });
    return data; // if data was complete
}

1 Answers1

0

Use as below:

function foo(){
$.ajax({
    url: "test.html",
    param: {} 
 }).done(function(data) {
      return data;        
 });
}
Amit
  • 15,217
  • 8
  • 46
  • 68