From 8aa780cc33333e543b741f878098c3b2b142b7cd Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 15 Nov 2015 19:56:58 -0800 Subject: [PATCH] Make our AJAX requests work in Maxthon. #593 --- src/General/$.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/General/$.coffee b/src/General/$.coffee index 518895184..c34478460 100644 --- a/src/General/$.coffee +++ b/src/General/$.coffee @@ -67,8 +67,14 @@ $.ajax = do -> r.setRequestHeader 'If-Modified-Since', lastModified[whenModified][url] if lastModified[whenModified]?[url]? $.on r, 'load', -> (lastModified[whenModified] or= {})[url] = r.getResponseHeader 'Last-Modified' if /\.json$/.test url - r.responseType = 'json' + options.responseType ?= 'json' $.extend r, options + # XXX https://code.google.com/p/chromium/issues/detail?id=119256 (Maxthon is still on Chromium 30) + if options.responseType is 'json' and r.responseType isnt 'json' and delete r.response + Object.defineProperty r, 'response', + configurable: true + enumerable: true + get: -> return JSON.parse r.responseText $.extend r.upload, upCallbacks r.send form r