Answers for "js promis with ajax"

0

js promis with ajax

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 November-25-2020
0

js promis with ajax

doTheThing()
  .then((data) => {
    console.log(data)
    doSomethingElse()
  })
  .catch((error) => {
    console.log(error)
  })
Posted by: Guest on November-25-2020
0

javascript promise with ajax

function doTheThing() {
  $.ajax({
    url: window.location.href,
    type: 'POST',
    data: {
      key: 'value',
    },
    success: function (data) {
      console.log(data)
    },
    error: function (error) {
      console.log(error)
    },
  })
}
Posted by: Guest on December-09-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language