簡體   English   中英

用ajax和jsp進行表單驗證不起作用

[英]form validation with ajax and jsp doesn't work

我正在嘗試使用jsp和ajax開發用戶名驗證,但是這樣的錯誤信息

POST ://localhost:8080/web_application/deneme.jsp

顯示錯誤: 405 (Method Not Allowed)

這是我的jsp頁面,這里出了什么問題

<html>
<body>

    <form name="form" id="form">
        <input type="text" name="username" id="username"> 

        <br>
        <input
            type="submit" name="register" value="Sign up">
    </form>

    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script
        src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/jquery.validate.min.js"></script>


    <script type="text/javascript">

      $(document).ready(function(){
            $("#form").validate({
                rules : {
                    username : {

                        required:true,

                        remote : {
                            url : "deneme.jsp",
                            async : false,
                            type : "post",
                            data : {
                                username : function() {
                                    return $("#username").val()
                                }
                            }
                        }


                    }
                },
                messages : {
                    username : {
                        required:"Require Field" ,remote:"already exist"
                    }
                }
            });
      });
    </script>

</body>
</html>

代替:

 <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/jquery.validate.min.js"></script>

您的javascript文件鏈接位置中缺少http

使用以下內容:

 <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/jquery.validate.min.js"></script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM