在ajax提交后保持bootstrap模式打开

时间:2014-07-08 13:45:13

标签: jquery ajax bootstrap-modal

我在bootstrap模式中通过ajax发送<form>数据。如何在返回值之前打开模态窗口,然后显示通知<div>

通知div将显示表单验证,并手动关闭用户需要单击关闭按钮或模态窗口外的模式。

以下是我的代码,简化版:

$.post(url, {
    data:data }
    ,function(html){
        if(html==1){
            //show <div class="A">  here
        }
        else{
           //show <div class="B">  here
        }
});

1 个答案:

答案 0 :(得分:1)

使用$ .ajax

$.ajax({
    type: 'POST',
    url: url,
    data: data,
    beforeSend: function() {
        // Write code for showing the modal here
       // You can also set a loading image here
    },
    success: function(html) {
        // code for success notification
    },
    error: function(xhr) { // if error occured
        // code for showing error
    }
});
相关问题