So for JQuery Ajax call we can do something like below
function checkUserName() {
var flag=false;
$.ajax({
type : "get",
url : "/vclub/verify/checkUserName.do",
data : {lastName: "jason"},
success : function(data) {
if (data) {
alert("flag now true");
flag=true;
}
}
});
alert(flag);
return flag;
}
And flag never becomes true.
I searched the forum and been told to use callback functions.
Why can I not use success function (which I believe that success function called after success ajax response??) to assign flag variable?
What's the difference between "THEN()" and "Success function"?
To me both of them seems about the same.
What am I missing?
Thank you. Again Thank you for sharing your knowledge.
But what is the diff between Then and Success?