jquery - How to get request header from ajax -



jquery - How to get request header from ajax -

i using ajax. here. can response header.

var geturl = $.ajax({ type: urltype, url: url, data:data, beforesend:function(xhr){console.log(xhr)}, success: function(data) { $('.response').show(); $('#resdata').val(data); $('#resheader').val(geturl.getallresponseheaders()); // console.log(geturl.header) }, error: function(jqxhr, textstatus, errorthrown) { }, complete: function (xmlhttprequest, textstatus) { console.log(xmlhttprequest) } });

in this, didn't set headers. default, pass request header shown in network tab.

i have request header in beforesend, success & complete.

how can req header ajax

this req header can in network tab

accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 accept-encoding:gzip,deflate,lzma,sdch accept-language:en-us,en;q=0.8 cache-control:max-age=0 connection:keep-alive host:localhost if-modified-since:fri, 14 nov 2014 03:54:43 gmt if-none-match:"f60-507c996d5d401"

as user milkovsky suggested in post :

$.ajax({ type:"post", beforesend: function (request) { request.setrequestheader("authority", authorizationtoken); }, url: "entities", data: "json=" + escape(json.stringify(createrequestobject)), processdata: false, success: function(msg) { $("#results").append("the result =" + stringifypretty(msg)); } });

that's illustration of custom headers.

jquery ajax

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -