How to send headers with ajax request ?

I've been trying to add headers to ajax request through enyo ajax call.But I couldn't find any headers sent with requset when I checked in network tab of chrome console.These are the few lines that I've written.

var req = new enyo.Ajax({
url: "http://www.w3schools.com/website/Customers_MYSQL.php",
// url:"C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/json.docx",
method: "GET",
contentType:"text/plain",
postbody:"hai hello how are you",
headers:{"X-My-Header": "My Value", "Mood": "Happy" }
});
var res = req.response(this, "handleData").go();

Finally, what I need is to send both pre-defined and custom headers through ajax request.So,can you please help me in doing this!!!!!

Comments

  • The enyo.Ajax code looks right, except it should be postBody, not postbody. See if that helps? If not, can you share a screenshot of the Chome debug console where the request headers are displayed?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!