Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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)
    },
   })
  })
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Promisify #ajax #call
ADD COMMENT
Topic
Name
5+7 =