You cannot do that. .get(), like any other ajax method, it runs asynchronously (unless you explicitly ran it synchronously, which is not highly recommended). So the best thing you can do is pass a callback.
function checkResults(value, callback) {
$.get("checkDuplicates.php", {
value: value
}, function(data) {
if(data == "0") {
if(typeof callback === 'function')
callback.apply(this, [data]);
} else {
}
}
}
checkResults(55, function(data) {
});
jAndy source
share