The problem with promise

as soon as I came into contact with promise, I wrote a demo by myself. Ask

.

Why my then only executes once, and how to make it execute multiple times

    var test = 0;
    var promise = new Promise(resolve => {
        $(".btn").on("click",()=>{
            console.log(testPP +"----------")
            resolve(test)
        })
    })
    promise.then((data)=>{
        console.log(data+"*********")
    })

clipboard.png

Feb.28,2021

var test = 0;
$('.btn').on('click',()=>{
    console.log(testPP +"----------");
    Promise.resolve(test).then(successfn);
})

function successfn(data){
    console.log(data+"*********");
}

because Promise doesn't work this way, a Promise object can only be resolve or reject once, just like a request ( request ) you can only reply ( response ) once. If you must use Promise , you can only create a new Promise and then resolve every time click, but it doesn't make sense.

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-1c241d1-3ba6e.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-1c241d1-3ba6e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?