jQuery menunggu fungsi selesai
// *use promisses*//
//example
function function(info) {
return new Promise(function(resolve, reject) {
$.ajax({
method: "POST",
url: "file.php",
data: {
"info": info,
},
success: function(data) {
resolve(data) // Resolve promise and go to then()
},
error: function(err) {
reject(err) // Reject the promise and go to catch()
}
});
});
}
//in the call of function
function("data").then((data)=>{
console.log(data);
});
Clumsy Crane