Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Laravel SweetAlert2-发送Aajax请求时阻止UI_Javascript_Html_Laravel_Sweetalert_Sweetalert2 - Fatal编程技术网

Javascript Laravel SweetAlert2-发送Aajax请求时阻止UI

Javascript Laravel SweetAlert2-发送Aajax请求时阻止UI,javascript,html,laravel,sweetalert,sweetalert2,Javascript,Html,Laravel,Sweetalert,Sweetalert2,我有一个按钮,用户点击并询问他是否想继续请求。 如果他选择“OK”,一个AJAX请求将被发送到后端,当收到响应时,将触发一个新的sweet警报,通知用户请求是否已成功执行 我遇到的问题是,在用户确认发送请求和收到响应之间,用户可以自由地再次单击触发请求的按钮 是否有任何方法可以在发送请求时阻止UI和/或在收到响应时关闭第一个sweetalert并触发第二个sweetalert以通知用户请求结果 代码如下: "use strict"; function likeProperty(matchid

我有一个按钮,用户点击并询问他是否想继续请求。 如果他选择“OK”,一个AJAX请求将被发送到后端,当收到响应时,将触发一个新的sweet警报,通知用户请求是否已成功执行

我遇到的问题是,在用户确认发送请求和收到响应之间,用户可以自由地再次单击触发请求的按钮

是否有任何方法可以在发送请求时阻止UI和/或在收到响应时关闭第一个sweetalert并触发第二个sweetalert以通知用户请求结果

代码如下:


"use strict";

function likeProperty(matchid) {

    swal.fire({
        buttonsStyling: false,
        text: "¿Esta seguro que desea enviar una notificación al agente informando que estás interesado en su propiedad?",
        type: "question",
        confirmButtonText: "Si, enviar!",
        confirmButtonClass: "btn btn-sm btn-bold btn-brand",
        showCancelButton: true,
        cancelButtonText: "No, cancelar",
        cancelButtonClass: "btn btn-sm btn-bold btn-danger"

    }).then(function (result) {
        if (result.value) {

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $.ajax({
                type: 'POST',
                url: '/processes/offerdemand/matchlike/'+ matchid,
                data: {
                    'id': matchid,
                },
                dataType: 'JSON',

                success: function (data) {

                    if (data.status != 200) {

                        console.log(data.status);
                        swal.fire({
                            "title": "",
                            "text": "Ocurrió un error, contactar al administrador",
                            "type": "error",
                            showConfirmButton: !1,
                            timer: 3000,
                            onClose: () => {
                                window.location.reload();
                            }
                        });

                    }

                    if (data.status = 200) {
                        swal.fire({
                            "title": "",
                            "text": "Se ha notificado al agente que estas interesado en su propiedad!",
                            "type": "success",
                            showConfirmButton: !1,
                            timer: 3000,
                            onClose: () => {
                                window.location.reload();
                            }
                        });
                    }

                    // hide like button
                    $('#likeprop'+matchid).hide();
                    // show like button
                    $('#unlikeprop'+matchid).show();
                    // window.location.reload();
                    console.log(data);
                },
            })
            var xhr = $.ajax();
            console.log(xhr)

        }
    });
}
看一看“排队”谢谢@Chris看起来“排队”不是我需要的,谢谢!