Hi, I'm trying to use $.post within a function, get the results, then return the function true or false based on the results of the $.post callback. However, the callback seems to occur, AFTER the return event of the parent function.
Here's the current code the ret variable is always undefined but if I alert() it within the $.post callback, it returns the correct result;
function elementExists(key, type, path, appid, pid){
var ret;
$.post('?do=elExists', {key: key, type: type, path: path, appid: appid, pid: pid},function(data){
ret = data;
});
alert(ret);
return ret;
}