Bearer token through ajax headers not working


Hey guys,
as i try to add Header to my ajax request i get no server response,
in google chrome i get this error "net::ERR_SPDY_PROTOCOL_ERROR"
and in
mozzila firefox i get no response,
as i checked in mozzila console there is request method OPTION with no status code,
but as i remove http headers(xhr.setRequestHeader()) i get the response

I am using free hosting plans of 000webhost for testing purposes ,
please help me to solve this problem

here is my ajax code

const url = ""
    let xhr = new XMLHttpRequest()'POST',url,true)

    let my_token = 'idjzoi59599frkdijzjd'
    xhr.setRequestHeader("Authorization","Bearer " + my_token)
    xhr.onreadystatechange = function() {
      if(xhr.readyState == 4 && xhr.status == 200) {
  xhr = null


@Supun @Infinity @teodor


Hi @extremety1989

Please read the following topic for more information:

I am afraid your only choice is to use jQuery in order to perform XHR, as 000webhost does not allow OPTIONS method on free plans.