繁体   English   中英

当我包含jquery.js文件时出现未捕获的错误

[英]Getting an uncaught error when i included the jquery.js file

以下链接包含我的原始问题:“ 使用摘要式身份验证来验证用户名和密码时,javascript中出现错误

通过遵循建议, I included the jquery.js filejquery-1.4.2.min.js文件。 之后,我得到的错误为"Uncaught TypeError: Object function (a,b){return new c.fn.init(a,b)} has no method 'Class' ". 谁能帮我解决这个问题。 提前致谢...

您需要包括位于此github存储库中的文件以定义Class函数。

https://github.com/Arrowgroup/JSDigestAuth/blob/master/src/main/webapp/resources/js/jquery.class.min.js

实际上,查看那里的示例,您将需要在标题中包含所有这些内容,如果您没有按此顺序排列这些脚本文件,那么您将得到未声明的错误,就像您在两个问题中都看到的那样。

顺便说一句,快速浏览一下此代码就可以看出它是……好吧……让我们说“不太好”。 举例来说,这可能会有所帮助,但我看到了许多并非领先实践的事情。

    <script type="text/javascript" src="jquery.min.js" ></script>
    <script type="text/javascript" src="jquery.class.min.js" ></script>
    <script type="text/javascript" src="md5-min.js" ></script>
    <script type="text/javascript" src="digest-auth.js" ></script>

    <script type="text/javascript">
        var digestAuth = new pl.arrowgroup.DigestAuthentication(
            {
                onSuccess : function(response){
                    $("#response").html(response);
                },
                onFailure : function(response){
                    $("#response").html('Invalid credentials !!!');
                },
                cnonce : 'testCnonce'
            }
        );
        function callREST(){
            digestAuth.setCredentials($('#user').val(),$('#password').val());
            digestAuth.call('/restauth/user/echo');
        }
    </script>

暂无
暂无

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

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