Why is the interface called once and requested twice?

enters the page only once, but the breakpoint skips to this method and executes the method again after a request. What is the reason for this?

The order of

breakpoints is that they are called twice first and do not enter the method. After calling the method twice, I went into the method again, and then walked the method twice.

//
function getAllUsers(pagenum) {
    $.ajax({
        url: "/user/getAllUsers",
        data: {
            "pagenum": pagenum
        },
        type: "post",
        dataType: "json",
        success: function(data) {
            if (data.flag == "success") {
                $("tbody").html(" ")
                var list = data.Data;
                var count = data.count;
                //
                for (var i = 0; i < list.length; iPP) {

                    var num = i + (pagenum - 1) * 10 + 1; //

                    $("tbody").append(
                        `<tr id="${list[i].uid}">  
                        <td>${num}</td>   
                        <td class="accountName">${list[i].username}</td>   
                        <td class="accountPass">${list[i].password}</td>  
                        <td class="role">${list[i].rolename}</td> 
                        <td class="lastTime">${list[i].lastlogintime}</td> 
                        <td class="lastIP">${list[i].lastloginip}</td> 
                        <td><i class="fa fa-edit modify" data-toggle="modal" data-target="-sharpmodifyUserModal" title=""></i>
                            <i class="fa fa-trash-o deleteUser" title=""></i>
                        </td> 
                        </tr>
                     `
                    )
                }

                //
                layui.use(["laypage"], function() {

                    var laypage = layui.laypage;
                    // 
                    laypage.render({
                        elem: "layPage" // id
                            ,
                        layout: ["prev", "page", "next", "limits",
                                "count"
                            ] // 
                            ,
                        limit: 10 // 
                            ,
                        count: count // 
                            ,
                        curr: pagenum // 
                            ,
                        groups: 3 // 
                            ,
                        theme: "-sharp1E9FFF" // 
                            ,
                        skip: true // 
                            ,
                        jump: function(obj, first) { // 
                            if (!first) {
                                $("tbody").html("");
                                getUserLog(obj.curr)
                            }
                        }
                    });
                })
            } else {
                layer.msg("", {
                    offset: "3.8%",
                });
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            console.log(XMLHttpRequest.status);
            console.log(XMLHttpRequest.readyState);
            console.log(textStatus);
        }
    })
}

$(function(){
    getAllUsers(1)
})
May.16,2022

you can see where the call stack is sent after the chrome breakpoint, and make sure there is another location to call.


whether the actual network has requested twice or the breakpoint has been there twice, these are two different things. Take a look at how many requests have been made in network


. It is also possible that the event bubbling of the button causes the request to be made twice


to add a log. Confirm whether the getAllUsers is triggered twice or the success is called back twice?


is the jquery or layui repeated reference to see if the same js library has requested 2 requests in the request


check whether one of the network screenshots is an OPTION request (method is option)

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