How to set content-type header in Angular.JS Ajax Call

Having worked in Jquery and its Ajax for some years, I thought the the internal workings of Angular.JS Ajax call is similar because code looked very similar or no change but I didn’t get the result as expected. Let us see what was the problem and how to resolve it.

Jquery Ajax Call Code


Angular Ajax Call Code (Equivalent of the above)


After looked at the Http Header in the Chrome Inspector, I realised that the Content-Type header passed was missing


Following stack overflow provided me the solution, it said that “You need to include a body with the request. Angular removes the content-type header otherwise


Modified Angular Ajax Call Code (With dummy body i.e. data : ‘’)


After setting the body, Content-Type was passed and I got my results.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s