Answers for "ajax pass array to php"

PHP
0

ajax pass array to php

const data = JSON.stringify([{a: 1}, {a: 2}, {a: 3}]);

const promise = $.ajax({
  type: "POST",
  url: "my-url/some-endpoint",
  data,
});

promise.done((response) => {
  console.log('Success');
  // Remember to parse your JSON string
  const stuff = JSON.parse(response);
});

promise.fail((response) => {
  console.log('Failed', response);
});

promise.always(() => {
  console.log('Complete');
});
Posted by: Guest on August-26-2021

Browse Popular Code Answers by Language