HTTP request from javascript using raw message including headers

前端 未结 4 775
说谎
说谎 2021-01-21 15:25

I know how to make an HTTP request to my REST api from javascript using jQuery or XMLHttpRequest. What I want to do now is make the request without setting properties for the he

4条回答
  •  庸人自扰
    2021-01-21 15:48

    You can possibly get an instance of the HmlHttpRequest object and use the setRequestHeader.

    jQuery has a beforeSend handler you can set to get the actual hxr object.

      $.ajax({
          beforeSend: function(xhr){
              xhr.setRequestHeader("name","value");
           }
      ...
      })
    

提交回复
热议问题