I am using jquery's ajax method to POST data to a server. I am using the servers API, and it is stated that in whatever request, I have to include this "authentication token" to access the data I need, either as an http header field or a header parameter.

I prefer to add it as an http header, but I don't know how to add it. I need help. Thank you. :D

Here's a part of my code. I wish to add a field for a token.

$.ajax({
  type: "POST",
  url: url,
  async: true,
  contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  success: function(){ alert("YEEHA!"); }
});

Where supported object.setRequestHeader(sName, sValue)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.