简体   繁体   English

单击引导警报的关闭按钮后,表单不起作用

[英]Form does not work after clicking close button of bootstrap alert

Im facing a really strange problem here. 我在这里面临一个非常奇怪的问题。 I use bootstrap for some of my tooltips alerts etc. Now I have a ajax form that responds error messages in a alert if something is wrong. 我将引导程序用于某些工具提示警报等。现在,我有了一个ajax表单,如果出现问题,它会在警报中响应错误消息。 This all works fine but when i click the "close" button of the alert box the alert dissapears but then the form submit button does not work anymore? 这一切都很好,但是当我单击警报框的“关闭”按钮时,警报消失了,但是表单提交按钮不再起作用了? I dont know why it's behaviour is like this can someone help me out? 我不知道为什么这是这样的行为,有人可以帮助我吗?

Also, when i do not close the alert, then when I enter new data and click on submit it does submit. 另外,当我没有关闭警报时,则当我输入新数据并单击“提交”时,它确实会提交。 Only after closing alert form does not submit anymore 仅在关闭警报表单后不再提交

Form (with error div) 表格(错误div)

<!-- ERROR BOX -->
<div id="regError" class="alert alert-error" style="margin-right: 20px; display: none;"></div>
<!-- ERROR BOX -->
<form id="registerform" action="ajax/register.php" method="post">
    <fieldset> <span class="help-block"><B>Jou gegevens</B></span>

        <input name="username" class="span4" type="text" value="Gebruikersnaam" onblur="onBlur(this)" onfocus="onFocus(this)" placeholder="Gebruikersnaam">
        <input name="email" class="span4" type="text" value="Email adres" onblur="onBlur(this)" onfocus="onFocus(this)" placeholder="Email adres">
        <input class="span4" type="text" value="Email adres (opnieuw)" onblur="onBlur(this)" onfocus="onFocus(this)" placeholder="Email adres (opnieuw)">
        <input class="span4" type="text" value="Wachtwoord" onblur="onBlur(this)" onfocus="onFocus(this)" placeholder="wachtwoord">
    </fieldset>

  <button type="submit" class="btn btn-primary" >Save changes</button>
  <button type="button" class="btn">Cancel</button>

javascript ajax call javascript ajax呼叫

$(document).ready(function () {
    $("#registerform").submit(function () {

        //Get al form data This = form and EL is element of the form
        var el = $(this),

            // get form action and method attribute
            url = el.attr('action'),
            type = el.attr('method'),

            // emty data array to fill with form data
            data = {}

            // The loop to get al form data
        el.find('[name]').each(function (index, value) {

            var el = $(this)
            name = el.attr('name'),
                value = el.val();

            //make data object
            data[name] = value;

        });

        //Do the ajax call
        $.ajax({
            type: type,
            url: url,
            data: data,
            success: function (response) {
                $('#regError').html(response);
                $('#regError').fadeIn();
            }
        })

        return false;
    })
})

the PHP is just to test if it works.. PHP只是为了测试它是否有效。

<?php
if (isset($_POST)) {
    echo '<button type="button" class="close" data-dismiss="alert">×</button>';
    print_r($_POST);
}

好吧,因为我找不到解决方案,所以我删除了关闭按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM