欧阳简之 > 谷歌浏览器控制台常用操作

热爱代码,对每一行代码保持一颗敬畏之心。


// 批量请求
var count = 0;
var ids = [1,2,3];

var intervalRequire = function (id) {
    if (count <= ids.length - 1) {
        $.ajax({
            type:'post',
            dataType: "json",
            data: {
                id: id
            },
            url: "https://www.example.com/api",
            success: function(data){
                console.log(data);
                if (data.result) {
                    count++;
                    intervalRequire(ids[count]);
                }
            },
            headers: {
                "x-csrf-token":"UTRpaVBSTkwhXxkCESs3Kh5nJxNpCCwIC2UxRAo8fD4XXQsfBCgEHg=="
            }
        });
    }
}

intervalRequire(ids[0]);
```js
tagged by none