javascript - 如何在 js 函数中调用模态而不单击模态按钮

标签 javascript twitter-bootstrap

如何在 js 函数中调用模态而不点击模态按钮?

if (email != "") {
        $.ajax({
            type: "POST",
            url: "ajax/email.php",
            data: 'email='+ email,
            cache: false,
            success: function(result){
                //alert(result);
                if (result == 'true') {
                    $.ajax({
                     //do some thing
                   });
                }
                else {
                    $("#sendemail").modal('show');
                    // there is no button for modal
                    return false ;
                }
            }
        });
}

现在,在其他情况下,模式不会打开,它位于另一个文件中。

最佳答案

您忘记用花括号关闭成功函数。

if (email != "") {
    $.ajax({
        type: "POST",
        url: "ajax/email.php",
        data: 'email='+ email,
        cache: false,
        success: function(result){
            //alert(result);
            if (result == 'true') {
                $.ajax({
                 //do some thing
               });
            }
            else {
                $("#sendemail").modal('show');
                return false ;
            }
       } // no syntex error
    });
}

关于javascript - 如何在 js 函数中调用模态而不单击模态按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26669359/

相关文章:

javascript - 图片显示在除 Safari 和 Chrome 之外的所有浏览器中

javascript - ECMA-262-v6 中的 'Symbol' 类型有什么意义?

javascript - AJAX 成功函数调用成功但未正确更新页面

javascript - HTML/Chart JS 从 Python Flask 反序列化 JSON

css - 在列的每一端对齐文本 - Bootstrap

javascript - 在加载时扩展 Bootstrap 树的一个分支

css - 强标签换行

css - 足以更改@media 以自定义 Bootstrap 网格中的最大宽度吗?

javascript,在开始颜色和结束颜色之间选择一个随机的十六进制颜色

html - Bootstrap 表,悬停一行时我可以更改最后一列中的内容可见性