Skip to content

Commit 234a445

Browse files
author
Jason Moon
committed
Accommodate HTML dataType, as requested in PR 13
1 parent 5532147 commit 234a445

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

jQuery.XDomainRequest.js

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

@@ -32,21 +33,18 @@ if (!jQuery.support.cors && jQuery.ajaxTransport && window.XDomainRequest) {
3233
var responses = {
3334
text: xdr.responseText
3435
};
35-
/*
36-
if (userType === 'html') {
37-
responses.html = xdr.responseText;
38-
} else
39-
*/
4036
try {
41-
if ((userType === 'json') || ((userType !== 'text') && jsonRegEx.test(xdr.contentType))) {
37+
if (userType === 'html' || htmlRegEx.test(xdr.contentType)) {
38+
responses.html = xdr.responseText;
39+
} else if (userType === 'json' || (userType !== 'text' && jsonRegEx.test(xdr.contentType))) {
4240
try {
4341
responses.json = jQuery.parseJSON(xdr.responseText);
4442
} catch(e) {
4543
status.code = 500;
4644
status.message = 'parseerror';
4745
//throw 'Invalid JSON: ' + xdr.responseText;
4846
}
49-
} else if ((userType === 'xml') || ((userType !== 'text') && xmlRegEx.test(xdr.contentType))) {
47+
} else if (userType === 'xml' || (userType !== 'text' && xmlRegEx.test(xdr.contentType))) {
5048
var doc = new ActiveXObject('Microsoft.XMLDOM');
5149
doc.async = false;
5250
try {

0 commit comments

Comments
 (0)