Skip to content
Permalink
Browse files

Allow the user to explicitly set a content-type header even when ther…

…e's no data being sent to the server. Fixes #1900.
  • Loading branch information
jeresig committed Dec 5, 2009
1 parent d684122 commit 25b0ba9f9612583033b902a0e40345463a3a71d0
Showing with 3 additions and 5 deletions.
  1. +3 −5 src/ajax.js
@@ -195,10 +195,8 @@ jQuery.extend({
lastModified: {},
etag: {},

ajax: function( s ) {
// Extend the settings, but re-extend 's' so that it can be
// checked again later (in the test suite, specifically)
s = jQuery.extend(true, {}, jQuery.ajaxSettings, s);
ajax: function( origSettings ) {
var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);

var jsonp, status, data,
callbackContext = s.context || window,
@@ -333,7 +331,7 @@ jQuery.extend({
// Need an extra try/catch for cross domain requests in Firefox 3
try {
// Set the correct header, if data is being sent
if ( s.data ) {
if ( s.data || origSettings.contentType ) {
xhr.setRequestHeader("Content-Type", s.contentType);
}

2 comments on commit 25b0ba9

@jaubourg

This comment has been minimized.

Copy link
Member

@jaubourg jaubourg replied Dec 5, 2009

origSettings can be undefined, should be s.data || origSettings && origSettings.contentType on line 334 (just found out while unit testing)

@jeresig

This comment has been minimized.

Copy link
Member Author

@jeresig jeresig replied Dec 5, 2009

Good call, landed: 9c1db29

Please sign in to comment.
You can’t perform that action at this time.