AmpersandJS / ampersand-model

Observable objects, for managing state in applications.
MIT License
84 stars 31 forks source link

Default content type to text/plain;charset=UTF-8 with ajaxConfig #78

Closed yamsellem closed 8 years ago

yamsellem commented 8 years ago

Is there a reason why body are send by default with a Content-Type to text/plain;charset=UTF-8? This is very painful.

Ok, this is on my side too. Using ajaxConfig is the reason of this, but I can't find why.

ajaxConfig: {
  beforeSend: function(xhr) {
    xhr.open(this.type, this.url + `?token=...`, true);
  },
yamsellem commented 8 years ago

Not related to ampersand-model. I'll post the solution here when I find it.

yamsellem commented 8 years ago

This is enough to fix the problem;

ajaxConfig: {
  beforeSend: function(xhr) {
    xhr.open(this.type, this.url + `?token=...`, true);
    Object.keys(xhr.headers).forEach(header => {
      xhr.setRequestHeader(header, xhr.headers[header]);
    });
  },