Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[CB-2806] Fix plugin loading when XHR doesn't return valid JSON

Take two!
  • Loading branch information...
commit 32b9e1c30649d228faa397bbc6216548c437742c 1 parent 5f56a0d
@clelland clelland authored agrieve committed
Showing with 7 additions and 12 deletions.
  1. +7 −12 lib/scripts/plugin_loader.js
View
19 lib/scripts/plugin_loader.js
@@ -94,24 +94,19 @@
// Try to XHR the cordova_plugins.json file asynchronously.
var xhr = new context.XMLHttpRequest();
- xhr.onreadystatechange = function() {
- if (this.readyState != 4) { // not DONE
- return;
- }
-
+ xhr.onload = function() {
// If the response is a JSON string which composes an array, call handlePluginsObject.
// If the request fails, or the response is not a JSON array, just call finishPluginLoading.
- if (this.status == 200 || this.status == 0) {
- var obj = JSON.parse(this.responseText);
- if (obj && obj instanceof Array && obj.length > 0) {
- handlePluginsObject(obj);
- } else {
- finishPluginLoading();
- }
+ var obj = JSON.parse(this.responseText);
+ if (obj && obj instanceof Array && obj.length > 0) {
+ handlePluginsObject(obj);
} else {
finishPluginLoading();
}
};
+ xhr.onerror = function() {
+ finishPluginLoading();
+ };
xhr.open('GET', 'cordova_plugins.json', true); // Async
xhr.send();
}(window));
Please sign in to comment.
Something went wrong with that request. Please try again.