Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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
Jquery 单击提交按钮后关闭模式(ajax成功)_Jquery_Ajax_Twitter Bootstrap_Modal Dialog_Bootstrap Modal - Fatal编程技术网

Jquery 单击提交按钮后关闭模式(ajax成功)

Jquery 单击提交按钮后关闭模式(ajax成功),jquery,ajax,twitter-bootstrap,modal-dialog,bootstrap-modal,Jquery,Ajax,Twitter Bootstrap,Modal Dialog,Bootstrap Modal,我知道这个问题在StackOverflow中已经被问过好几次了,但我不能在给出建议的情况下让它工作 所以基本上我有这个模式在我看来: <div id="createFolderModal" class="modal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <!- (..

我知道这个问题在StackOverflow中已经被问过好几次了,但我不能在给出建议的情况下让它工作

所以基本上我有这个模式在我看来:

<div id="createFolderModal" class="modal">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <!- (...) -->
        </div>
        <div class="modal-body">
            <form class="form-horizontal">
                <fieldset>
                    <div class="form-group">
            <!- (...) -->
                    </div>
                </fieldset>
            </form>
        </div>
        <div class="modal-footer">
            <button type="submit" class="btn btn-primary" onclick="createFolder()">Create</button>
        </div>
    </div>
</div>
那么我的剧本是:

function createFolder() {
        // (...)

        $.ajax({
            type: "Post",
            url: '@Url.Action("CreateFolder", "ManageFiles")',
            data: { name: path },
            dataType: "json",
            traditional: true,
            success: function (data) {
                //close the modal
                $('#createFolderModal').modal('hide');
                //$('#createFolderModal').modal('toggle');

                document.getElementById("inputFolderName").value = ""; // to empty the input field
            }
        });
    }
所以,正如你所看到的,我已经尝试了下面的说明,但都没有奏效。在所有关于StackOverflow的帖子中,这是唯一的建议,所以我不知道在我的情况下会有什么错误

$('#createFolderModal').modal('hide');
$('#createFolderModal').modal('toggle');
还在我的按钮中尝试了data dismission=“modal”,但没有成功

提前感谢您的帮助。

代替

$('#createFolderModal').modal();
使用

然后

$('#createFolderModal').modal('hide'); to hide it.

你能用这个
$('#createFolderModel')检查一下吗如何
$('#CreateFolderModel')。隐藏()?如果要关闭模式,必须使用
模式(“显示”)
模式(“隐藏”)
。不
show()
/
hide()
method@BasantaMatia谢谢你的建议,但对我来说没有用。@Ignatius非常感谢,它奏效了@我的用户名21试试这个solution@myusername21,这是bootstrap推荐的方法。
$('#createFolderModal').show(); to open the dialog 
$('#createFolderModal').modal('hide'); to hide it.