Fixes #8219. Introduces the mimeType option to override content-type header in conversion (and in native xhr when possible). Adds companion overrideMimeType method on jqXHR object (it simply sets the option). Unit test added.
This commit is contained in:
parent
806d9ce811
commit
f6e173437e
3 changed files with 42 additions and 1 deletions
10
src/ajax.js
10
src/ajax.js
|
@ -426,6 +426,14 @@ jQuery.extend({
|
|||
return match || null;
|
||||
},
|
||||
|
||||
// Overrides response content-type header
|
||||
overrideMimeType: function( type ) {
|
||||
if ( state === 0 ) {
|
||||
s.mimeType = type;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
// Cancel the request
|
||||
abort: function( statusText ) {
|
||||
statusText = statusText || "abort";
|
||||
|
@ -827,7 +835,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
|
|||
while( dataTypes[ 0 ] === "*" ) {
|
||||
dataTypes.shift();
|
||||
if ( ct === undefined ) {
|
||||
ct = jqXHR.getResponseHeader( "content-type" );
|
||||
ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue