小编sad*_*qar的帖子

setTimout()ajax请求无法成功运行

在下面的代码行中

setTimeout(Comet_IrsaliyeBelgeDurum(sGuid, belgeOid), 10000)
Run Code Online (Sandbox Code Playgroud)

不会使彗星功能等待10秒。功能正在连续运行。

setTimeout参数似乎无效。

如何使代码等待10秒?

function Comet_IrsaliyeBelgeDurum(sGuid, belgeOid) {

            var params = {
                sGuid: sGuid,
                belgeOid: belgeOid
            }

            $.ajax({
                type: "post",
                dataType: "json",
                data: params,
                url: '/BetonHareketler/H_BetonIrsaliyeBelgeDurum',
                success: function (data) {

                    if (data.isSuccess) {

                        if (data.entity == 2 || data.entity == 4) {
                            toastr.success(data.SuccessfullMessage, '??lemi Ba?ar?l?');
                        }
                        else {
                            toastr.info(data.SuccessfullMessage, '??lemi Ba?ar?l?');
                            setTimeout(Comet_IrsaliyeBelgeDurum(sGuid, belgeOid), 10000);
                        }

                    }
                    else {
                        toastr.error(data.SuccessfullMessage, '??lemi Ba?ar?s?z');
                    }

                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert("Ba?lant? Hatas?. Sayfaya Yenileyin");
                    window.location.replace(window.location.href);
                }
            });

        }
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery

1
推荐指数
1
解决办法
42
查看次数

标签 统计

ajax ×1

javascript ×1

jquery ×1