-1

I read a lot but i think that i'm not getting it.

I read this duplicated post many times, and still can't figure it out how to make work. I working with code from another person and can't go crazy on the code.

How can i get a callback response to use outside the function? This code is in a function, that is in another function.

$.ajax({
    method: "POST",
    url: "test.php",
    data: data
}).done(function(resp){
    res = resp;
});
return res;

I get

ReferenceError: res is not defined
return res;
Community
  • 1
  • 1
Mateus Silva
  • 756
  • 2
  • 8
  • 20

1 Answers1

0

You need to define var then u can use it in anywhere in function E.G. var res;

Jinesh Gandhi
  • 67
  • 1
  • 11