1

How to set headers using Ajax request? in below code

$.ajax({ type: type, //GET or POST or PUT or DELETE verb url: requestURL, // Location of the service // contentType: "application/x-www-form-urlencoded", // content type sent to server dataType: "xml", //Expected data format from server processData: false, //True or False success: successCallback, //On Successfull service call error: serviceFailed// When Service call fails }); 

1 Answer 1

1

Request headers can be managed using beforeSend(jqXHR, settings) function and the setRequestHeader method, e.g.

$.ajax({ ... beforeSend : function(xhr) { xhr.setRequestHeader('content-Type', 'application/x-www-form-urlencoded'); } }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.