Delayed execution cannot be achieved by executing setTimeout in for loop

//
$(".forExecute").click(function(){
    var tableSign = $("-sharptableSign").val();
    if(!(tableSign > 0)){
        layer.msg("");
        return;
    }
    var forNum = $("-sharpforNum").val();
    for(var i = 1; i <= forNum; iPP){
        var data = {
            "tableSign":tableSign,
            "pageNo":i,
            "pageSize":$(".pageSize").val(),
            "startDate":$(".startDate").val()    
        };
        setTimeout(executeDataCopy(data),5000);
    }
})

function executeDataCopy(data){
    $.ajax({
        type: "get",
        url: "executeCopyData.do",
        data:data, 
        dataType: "json",
        success: function(data){
            if(data != null && data.success != null){
                layer.alert(data.msg);
            } else {
                layer.alert(",");
            }
        }
    });
}

setTimeout ( executeDataCopy (data) , 5000);
this sentence executeDataCopy has been executed immediately, and you can pass parameters in the following ways:
setTimeout ( executeDataCopy , 5000 executeDataCopy data);


setTimeout(executeDataCopy(data),5000);
executeDataCopy(data);
:
setTimeout(function(){
    executeDataCopy(data)
},5000);

setTimeout(executeDataCopy,5000,data);

setTimeout(function(){
    executeDataCopy(data)
},5000);


that's fine

for(var i =1; i<10; iPP){
        (function(a){
            var data = 123456;
            setTimeout(function(){
                console.log(data);
            }, **a*2000**);
        })(i);
}

setTimeout the first parameter is Function , and you pass a executeDataCopy (data) , which is a method call (not the method itself). In fact, what you pass to setTimeout is undefined , which can be changed according to the above methods.

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