title: Simple JWT Auth using Jquery
body: <p>I am trying to do a simple JWT Authentication using only JQuery. I have already tested the backend with postman and everything seems to work in there.</p>
  
  <p>Here's how my frontend code looks like </p>
  
  <pre><code>$("#send").click(function(){
      var name = $('#name').val();
      var password = $('#password').val();
      var token = ''
      $.ajax({
        type: 'POST',
        url: '/authenticate',
        data: { name: name , password: password },
        success: function(resultData){
          var token = resultData.token;
          // console.log(token);
          $.ajax({
            type: 'GET',
            url: '/memberinfo',
            headers: {"Authorization": token},
            success: function(data){
               $(location).attr('href', '/memberinfo')
            }
          });
        }
      });
  });
  </code></pre>
  
  <p>so when I get redirected to the memberinfo page it shows me I am unauthorised. Not quite sure if I am doing the Ajax calls properly. Would be really helpful if some one could direct me the right way. Thanks</p>