🌐 AI搜索 & 代理 主页
Skip to content

Commit 25b0ba9

Browse files
committed
Allow the user to explicitly set a content-type header even when there's no data being sent to the server. Fixes #1900.
1 parent d684122 commit 25b0ba9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/ajax.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,8 @@ jQuery.extend({
195195
lastModified: {},
196196
etag: {},
197197

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

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

0 commit comments

Comments
 (0)