Js controls the order in which ajax is executed, but occasionally returns out of order.

    $.ajax({
        data:{
            delayNum:$("-sharpajax-one").val(),
        },
        url: "/test/one.do?callback?",
        calback:"jsonp"+new Date().getTime(),
        type:"post",
        callback:"callback",
        dataType:"jsonp",
        success:function(data){
            console.log(data);
            alert(data.result);
            }
    }).then(
        function(){
            return $.ajax({
                data:{
                    delayNum:$("-sharpajax-two").val(),
                },
                calback:"jsonp"+new Date().getTime(),
                url:"/test/two.do?callback?",
                type:"post",
                dataType:"jsonp",
                success:function(data){
                    console.log(data);
                    alert(data.result);
                }
            });
        }
    ).then(
        function(){
            return $.ajax({
                data:{
                    delayNum:$("-sharpajax-three").val(),
                },
                calback:"jsonp"+new Date().getTime(),
                url:"/test/three.do?callback?",
                type:"post",
                dataType:"jsonp",
                success:function(data){
                    console.log(data);
                    alert(data.result);
                }
            });
        }
    )
Mar.06,2021

write it this way:

  

the third request should be written in the second then.

Menu