Advertisement
inilim

Untitled

May 6th, 2024
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export async function asyncAjax(obj) {
  2.     return await (function (){
  3.         return new Promise((resolve) => {
  4.         //
  5.             obj.success = obj.success || function (res) {
  6.                 resolve({
  7.                     response: res,
  8.                     code: 200,
  9.                 });
  10.             };
  11.             //
  12.             obj.error = obj.error || function (res) {
  13.                 resolve({
  14.                     response: res.responseJSON,
  15.                     code: res.status,
  16.                 });
  17.             };
  18.  
  19.             $.ajax(obj);
  20.         });
  21.     })();
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement