diff options
author | Matt Friedman <maf675@gmail.com> | 2015-05-04 10:27:11 -0700 |
---|---|---|
committer | Matt Friedman <maf675@gmail.com> | 2015-05-04 10:27:11 -0700 |
commit | c7a0b4479d2e4cfeefbfd951e499fc20da4051c4 (patch) | |
tree | 7c103858f4df14930675332a5e30653e7fe27d5e | |
parent | 4a7f905c6aaa93b4c7160e9c99fced3001189037 (diff) | |
download | forums-c7a0b4479d2e4cfeefbfd951e499fc20da4051c4.tar forums-c7a0b4479d2e4cfeefbfd951e499fc20da4051c4.tar.gz forums-c7a0b4479d2e4cfeefbfd951e499fc20da4051c4.tar.bz2 forums-c7a0b4479d2e4cfeefbfd951e499fc20da4051c4.tar.xz forums-c7a0b4479d2e4cfeefbfd951e499fc20da4051c4.zip |
[ticket/13771] Only handle valid JQHXR response objects
PHPBB3-13771
-rw-r--r-- | phpBB/assets/javascript/core.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 33f4021cb9..bd791e668c 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -262,10 +262,13 @@ phpbb.ajaxify = function(options) { console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown); } phpbb.clearLoadingTimeout(); - var errorText = false; - var responseText = $.parseJSON(jqXHR.responseText); - if (typeof responseText.message === 'string' && responseText.message.length > 0) { - errorText = responseText.message; + var responseText, errorText = false; + try { + responseText = JSON.parse(jqXHR.responseText); + responseText = responseText.message; + } catch (e) {} + if (typeof responseText === 'string' && responseText.length > 0) { + errorText = responseText; } else if (typeof errorThrown === 'string' && errorThrown.length > 0) { errorText = errorThrown; |