简体   繁体   English

使用我的 jQuery Javascript 提交操作

[英]Submitting action with my jQuery Javascript

Here is my script and I don't understand why it don't work because it's very basic instructions...这是我的脚本,我不明白为什么它不起作用,因为它是非常基本的说明......

Can anyone help me?谁能帮我?

<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
    $(".bouton, #supprimer").button();
    $("#form").submit(function(event){
        if (confirm("ATTENTION : Cette action est irréversible, êtes vous certains de vouloir supprimer "+ <%= membre.getCn() %> +"?"))
        {
            alert("Utilisateur supprimé !");
        }
        else{
            event.preventDefault();
        }
    });
});
//]]>
</script>

The

..primer "+ <%= membre.getCn() %> +"?...

is wrong.是错的。 You need to change into either您需要更改为

..primer <%= membre.getCn() %> ?...

or:或者:

..primer "+ "<%= membre.getCn() %>" +"?...

You are mixing javascript and jsp here...您在这里混合 javascript 和 jsp ...

The issue is where you out the string from server script.问题是您从服务器脚本中取出字符串的位置。

Use quotes to make the string you out to convert to javascript string.使用引号将您输出的字符串转换为 javascript 字符串。 Or you can do it inline.或者你可以内联。

Use利用

confirm("ATTENTION : Cette action est irréversible, êtes vous certains de vouloir supprimer "+ "<%= membre.getCn() %>" +"?")

OR或者

confirm("ATTENTION : Cette action est irréversible, êtes vous certains de vouloir supprimer <%= membre.getCn() %>?")

instead反而

The issue is with the argument being passed to confirm statement.问题在于传递给确认语句的参数。
Try this:尝试这个:

<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function(){
        $(".bouton, #supprimer").button();
        $("#form").submit(function(event){
            if (confirm("ATTENTION : Cette action est irréversible, êtes vous certains de vouloir supprimer <%= membre.getCn() %> ?"))
            {
                alert("Utilisateur supprimé !");
            }
            else{
                event.preventDefault();
            }
        });
    });
    //]]>
    </script>

You must return true or false您必须返回 true 或 false

ex:前任:

$(document).ready(function(){
    $(".bouton, #supprimer").button();
    $("#form").submit(function(event){
        if (confirm("ATTENTION : Cette action est irréversible, êtes vous certains de vouloir supprimer "+ <%= membre.getCn() %> +"?"))
        {
            return true;
        }
        else{
            event.preventDefault();
            return false;
        }

        return false;
    });
});

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

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