Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.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 ajax成功后,Jquery对话框未关闭_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript ajax成功后,Jquery对话框未关闭

Javascript ajax成功后,Jquery对话框未关闭,javascript,jquery,ajax,Javascript,Jquery,Ajax,我想在ajax调用后关闭对话框,但它仍然显示在警报框的后面,请帮助如果不想将该对话框重新用作模式对话框,请尝试以下操作 function sendMsg(){ $.ajax({ beforeSend: function(){ $("#loading").dialog('open').html("<p>Please Wait...</p>"); },

我想在ajax调用后关闭对话框,但它仍然显示在警报框的后面,请帮助

如果不想将该对话框重新用作模式对话框,请尝试以下操作

function sendMsg(){

        $.ajax({
             beforeSend: function(){
                 $("#loading").dialog('open').html("<p>Please Wait...</p>");
              },
            url: "${pageContext.request.contextPath}/WhoopieeMerchantAppConversationList", //(dynamically generated by product item), //(dynamically generated by product item)
           type: "get",
           data:"to_userid="+document.getElementById('to_userid').value+"&store_id="+document.getElementById('store_id').value+"&merchant_id="+document.getElementById('merchant_id').value+"&msg="+document.getElementById('msg').value,
           success: ajaxSuccessHandler
        });
    }
    function ajaxSuccessHandler(obj) {
        if(obj=="error")
        {
            $('#loading').html("<p style='font-size:18px;'>Msg Already Sent</p>");
        }
        else
        {
            $("#loading").dialog("close");
            alert("Message Sent Successfully");
            var redirect_link = document.getElementById('redirect').value;
            setTimeout(function(){window.location.href=redirect_link},0);
        }
    }
或者在对话框中创建

$("#loading").dialog("close");
setTimeout(function(){
  alert("Message Sent Successfully");
  window.location.href=document.getElementById('redirect').value;
},100)

为什么警惕???只需在关闭对话框之前写入,因为我想在警报框中按ok后重定向,而不是在对话框中,所以使用模式对话框。警报将阻止任何脚本。或者将警报放在setTimeout内
close: function(){
  alert("Message Sent Successfully");
  window.location.href=document.getElementById('redirect').value;
},