1function functABC() {
2 return new Promise(function(resolve, reject) {
3 $.ajax({
4 url: 'myPage.php',
5 data: {id: id},
6 success: function(data) {
7 resolve(data) // Resolve promise and go to then()
8 },
9 error: function(err) {
10 reject(err) // Reject the promise and go to catch()
11 }
12 });
13 });
14}
15
16functABC().then(function(data) {
17 // Run this when your request was successful
18 console.log(data)
19}).catch(function(err) {
20 // Run this when promise was rejected via reject()
21 console.log(err)
22})