Answers for "Promisify with ajax call"

0

Promisify with ajax call

function doTheThing() {
  return new Promise((resolve, reject) => {
  $.ajax({
    url: window.location.href,
    type: 'POST',
    data: {
      key: 'value',
    },
    success: function (data) {
      resolve(data)
    },
    error: function (error) {
      reject(error)
    },
   })
  })
}
Posted by: Guest on April-10-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language