0

The following link contains my original question: "getting error in the javascript ,when authenticate the username and password using digest authentication"

By following the suggestions I included the jquery.js file and jquery-1.4.2.min.js files. After that im getting the error as "Uncaught TypeError: Object function (a,b){return new c.fn.init(a,b)} has no method 'Class' ". Can anyone help me to solve this. Thanks in advance...

6
  • When are you calling $.Class? Commented Feb 12, 2013 at 4:55
  • in tap function,i called $.Class.by using this marcin-michalski.pl/2012/11/01/… link (digestauth.js),i wrote my code. Commented Feb 12, 2013 at 4:57
  • Why? What are you trying to do with $.Class? Commented Feb 12, 2013 at 4:58
  • i want to authenticate username and password ,using digest authentication Commented Feb 12, 2013 at 4:59
  • @lucky what is jquery.js file? Is it another jquery plugin? Commented Feb 12, 2013 at 5:03

1 Answer 1

1

You need to include the file located in this github repository to define the Class function.

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

In fact looking at the example there, you will need all this in your header, if you don't have these script files in this order then you will get undeclared errors as you have seen in BOTH your questions.

As an aside, a quick glance at this code shown it to be... well... let's just say "not so good." As an example maybe it can be helpful but I saw many things which were not leading practices.

    <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>
Sign up to request clarification or add additional context in comments.

4 Comments

okay,thanks for your answer ,i will try this one.i have a doubt,can i include jquery.js library file ?
@lucky - you are special. Over 80% of all websites on the internet include that file without problem, including this one. please don't include it twice, jquery.js and jquery.min.js and jquery-1.4.2.min.js are all the same thing. The file you are missing in this question is jquery.class.min.js
Hogan,i have a doubt,can u clarify? here im getting the form values in var valuesUser = this.getLoginform().getValues(); in the variable ,in the success function .but in github link they are using a button
@lucky - this is really a different question and reveals a fundamental lack of understanding the functional requirements. What exactly are you trying to do? If you are trying to authenticate via a form then I would expect the submit would cause authentication on the server side. If you are authenticating on the client then you don't want to submit the form but handle it in javascript. In this case you would use a button and not an <input> of type submit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.