When will the changed quantity be sent to the backend after the shopping cart is added or deleted?

recently, I was working on a project with vue+elementUI. When I was doing a shopping cart, I was thinking about how it was sent to the backend when the number in the shopping cart changed. If I changed it once, it would definitely be bad. Then I went to Taobao to try. When I added it, there was a request about a second later (I don"t know, I guess). If I kept pressing on it, he would send it again when I stopped adding. How this is implemented, or the process of sending a number of requests or the like to the background. Solve


according to the description of the landlord, "function anti-shaking" to understand.


this is very simple
you npm install-S debounce, or write one yourself

function debounce (fn, time) {
    var t;
    return function (ctx) {
        clearTimeout(t)
        t = setTimeout(function() {
            fn.apply(ctx, [].slice.call(arguments,1));
        }, time);
    }
}

function sendAjax () {}

fn = debouncing(sendAjax);
fn(sendData);
< hr >

but why don't you add an OK button?


$(function(){
var time;
$(document).on('click','.inc',function(e){
clearTimeout(time);
time = setTimeout(function(){
//
},1000);//

});

});

Mobile phone codeword, not indented to understand. ^ _ ^
it's very simple to define a variable externally to store the timer. Each time you click the add button, use clearTimeout to release the stored timer, and then execute setTimeout, for a second to trigger the asynchronous event inside. If the button is clicked again within a second, the asynchronous content in setTimeout will be dropped by clear before it is executed.

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