Skip to content

Commit 4e2a3db

Browse files
author
Jason Moon
committed
Check response contentType if dataType wasn't set
1 parent 82beabe commit 4e2a3db

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

jQuery.XDomainRequest.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ if (!jQuery.support.cors && window.XDomainRequest) {
55
var httpRegEx = /^https?:\/\//i;
66
var getOrPostRegEx = /^get|post$/i;
77
var sameSchemeRegEx = new RegExp('^'+location.protocol, 'i');
8+
var jsonRegEx = /\/json/i;
89
var xmlRegEx = /\/xml/i;
910

1011
// ajaxTransport exists in jQuery 1.5+
@@ -37,7 +38,7 @@ if (!jQuery.support.cors && window.XDomainRequest) {
3738
} else
3839
*/
3940
try {
40-
if (userType === 'json') {
41+
if ((userType === 'json') || ((userType !== 'text') && jsonRegEx.test(xdr.contentType))) {
4142
try {
4243
responses.json = $.parseJSON(xdr.responseText);
4344
} catch(e) {

0 commit comments

Comments
 (0)