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