Promise Encapsulates ajax Want to Execute ajax Sequentially, But Found Not Executed Sequentially

  node.js, question

图片描述

The code is as follows:

function $myAjax(url, method, data, callback) {
 let p = new Promise(function(resolve, reject) {
 $Ajax.request({
 url: url,
 method: method,
 data: data,
 success: function(resp) {
 callback(resp);
 resolve();
 },
 failure: function(xhr) {
 //todo
 reject();
 bracket
 });
 });
 return p;
 bracket
 let $docs = document;
 $docs.getElementById('xxx').onclick = function() {
 $myAjax('https://mhd.uzai.com/api/CommonActive/GetPrizeGivingByUserid', 'get', { 'memberid': 1920740, 'activeid': 1 }, function(resp) {
 console.log(resp);
 console.log(1);
 }).then($myAjax('https://mhd.uzai.com/api/CommonActive/GetPrizeGivingByUserid', 'get', { 'memberid': 1920740, 'activeid': 1 }, function(resp) {
 console.log(resp);
 console.log(2);
 }));
 };  `

That is to say, sometimes I will print out 2 first and then print out 1;

The order of execution is: 1,2

Please give some advice!

$docs.getElementById('xxx').onclick = async function() {
 let resp1 = await $myAjax('https://mhd.uzai.com/api/CommonActive/GetPrizeGivingByUserid')
 let resp2 = await $myAjax('https://mhd.uzai.com/api/CommonActive/GetPrizeGivingByUserid')
 bracket