There are two ways to do this, you can use async false but is deprecated and you can always use a promise:
do a function like this:
function ajaxCallback(id){
return $.ajax({
method: "POST",
url: "../YourUrl",
data: { id: id}
})
}
then call it like this:
if (id != '')//
{
ajaxCallback(id)
.done(function( response ) {
//do something with your response
});
}
Hope it helps
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…