How to solve the problem that multiple calls to constructor mode will override the previous one?

problem description

original question: how to solve the problem that the promise of es6 cannot execute reslove multiple times?
the current problem: how to overwrite the previous problem if the constructor mode is called multiple times?

the environmental background of the problems and what methods you have tried

original description:
I encapsulate an ajax method and use promise, but I cannot execute resolve when a page calls this ajax method for the second time.
I try to find out that the state of promise can only be changed once, but I create a new promise every time I execute the method.
I think it may be related to my design pattern, if the design pattern is not changed. How to solve this?
now describes:
I encapsulated an ajax method using constructor mode?
but when the page is called multiple times, it will cause the previous ajax method to be overwritten.
how to modify the least amount of code to change the ajax method multiple times at the same time.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

var my = function() {
    // beforeAjax, ajax, afterAjax 
    
     * @param  {string}   url      [description]
     * @param  {object}   data     []
     * @param  {Function} callback []
     * @param  {object}   setting  [ajax]
    this.ajax = function(url, data, callback, setting) {
    
        // beforeAjax, ajax, afterAjax 
        new Promise((resolve, reject) => {
            beforeAjax(() => {
                resolve(0);
            });
        }).then(number => {
            return new Promise(resolve, reject) {
                ajax(() => {
                    resolve();
                });
            }
        }).then(() => {
            afterAjax(() => {
                console.log(url);
                callback();
            })
        });
    }
    return this;
}
window.$my = new my();

expected results

when calling, $my.ajax (url, data, callback, setting);
if the url passed in is a.com, b.com, c.com;
prints out c.com, c.com, c.com


it feels fine. Check to see if there is something wrong with other code (causing resolve to fail)

< hr >
var my= function(){
    return this
}
my.prototype.ajax= function(url, data, callback, setting) {
    
        // beforeAjax, ajax, afterAjax 
        new Promise((resolve, reject) => {
            beforeAjax(() => {
                resolve(0);
            });
        }).then(number => {
            return new Promise(resolve, reject) {
                ajax(() => {
                    resolve();
                });
            }
        }).then(() => {
            afterAjax(() => {
                console.log(url);
                callback();
            })
        });
    }
    window.$my = new my();

is that probably what you want?

< hr >

can be implemented in class, with better readability

class My{
    ajax(url, data, callback, setting) {
    
        // beforeAjax, ajax, afterAjax 
        new Promise((resolve, reject) => {
            beforeAjax(() => {
                resolve(0);
            });
        }).then(number => {
            return new Promise(resolve, reject) {
                ajax(() => {
                    resolve();
                });
            }
        }).then(() => {
            afterAjax(() => {
                console.log(url);
                callback();
            })
        });
    }
}
window.$my = new My();

this.ajax itself is not return, then cannot be mounted outside
promise is the first then execution, execute the second then, you do not return the value inside the second, and you cannot read the value when mounted outside

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30c16-402c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30c16-402c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?