aWebDeveloper aWebDeveloper - 1 year ago 125
jQuery Question

Pass accepts header parameter to jquery ajax

When I inspect the following code in Chrome Console it shows me a Request header


url: _this.attr('href'),
accepts: "application/json; charset=utf-8",


How do I set accept type as json. I don't want to set a custom header or use

Answer Source

Try this ,

  headers: {          
    Accept: "text/plain; charset=utf-8",         
    "Content-Type": "text/plain; charset=utf-8"   
  data: "data",    
  success : function(response) {  
    // ...

See this post for reference:

Cannot properly set the Accept HTTP header with jQuery

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download