How to use setRequestHeader in jquery 1.7.1 to send token through headers to RESTfull WebService
this is my code which is used in my html page to call RESTfull web Service
$.ajax({
type: "POST",
url: "http://10.163.14.56:9000/customerservice/HeaderRequestDet",
beforeSend: function (xhr) { xhr.setRequestHeader("foo", "bar") },
success: function() {
alert('Success!' + "authHeader"); },
error:function(request, status, error)
{ alert("Error"+error) //alert(request.responseText); } });
the above code is not able to connect REST full Web Service but it is invoking if i remove beforeSend function
and also am getting the following information in Firbug
Request URL:
Request Method:
OPTIONS
Status Code:
HTTP/1.1 200 OK
Request Headers 10:53:21.934
Accept: text/html,application
xhtm+xml,application/ xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-us,en;q=0.5
Access-Control-Request-Headers:foo
Access-Control-Request-Method:POST
Cache-Control:no-cache
Connection:keep-alive
Host:10.163.14.56:9000
Pragma:no-cache
User-Agent:Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1
Response Headers Δ9ms
Allow:POST,GET,OPTIONS,HEAD
Content-Length:0Date:Tue, 18 Sep 2012 05:23:21 GMT
Server:Jetty(7.5.4.v20111024)
How to send header information to RESTfull Service through setRequestHeader in jquery 1.7.1
Please give me the solution to solve it...
Thanks