1const data = JSON.stringify([{a: 1}, {a: 2}, {a: 3}]);
2
3const promise = $.ajax({
4 type: "POST",
5 url: "my-url/some-endpoint",
6 data,
7});
8
9promise.done((response) => {
10 console.log('Success');
11 // Remember to parse your JSON string
12 const stuff = JSON.parse(response);
13});
14
15promise.fail((response) => {
16 console.log('Failed', response);
17});
18
19promise.always(() => {
20 console.log('Complete');
21});