wait for ajax to finish
function functABC() {
return new Promise(function(resolve, reject) {
$.ajax({
url: 'myPage.php',
data: {id: id},
success: function(data) {
resolve(data) // Resolve promise and go to then()
},
error: function(err) {
reject(err) // Reject the promise and go to catch()
}
});
});
}
functABC().then(function(data) {
// Run this when your request was successful
console.log(data)
}).catch(function(err) {
// Run this when promise was rejected via reject()
console.log(err)
})
Also in JavaScript:
- js module.exports documentation comments
- javascript to help find overflow elements
- ngx-translate angular 11
- How can I upload files asynchronously
- back press subscriptions i is not a function react native
- math js
- npm check updates
- get number of creeps screeps
- javascript ceiling
- React looping hooks to display in other hook
- refresh page on button click jquery
- display array in div javascript
- check equality numbers javascript
- function in react
- submitting login and sign up forms using AJAX
- Your global Angular CLI version (11.0.2) is greater than your local version
- v-for vue
- ngingx proxy express get real ip
- javacript is checkbox checked
- angularjs find and update object in array
- jquery table row calculation
- how to get width of inline elements js
- open google chrome in puppeteer macos
- jquery do something if toggle open and close