Ajax Request with header Authorization

1

I'm trying to make an ajax request but it needs a BASIC authentication, follow my code:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script>$(function(){$.post({url:link,contentType:"application/json",
        data:"1",
        headers: {'Authorization': 'Basic token'},
        success: function(data) {
          console.log(data)
        }, error: function(err) {
          console.log(err)
        }
      });
    });

</script>

* I put link / token for confidentiality, but they are correct. * I made this request by PHP with same token and parameter and it worked.

Can anyone help me? Returns 401 (Unauthorized) / Response for preflight has invalid HTTP status code 401.

    
asked by anonymous 03.08.2018 / 16:03

0 answers