Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloud.com.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Moura <itsme@paulomoura.com>2017-10-06 11:37:59 +0300
committerJos Poortvliet <jos@opensuse.org>2017-10-06 12:07:09 +0300
commit1c2025b32c5039fbb7e72f9202b4354751ebcbbf (patch)
treed7cb6eed477658bf7010d0f13b0cfd6c84cf8b11 /page-providers.php
parentb4ddd862ae1461267cdff3765acacd1ea1cd05b9 (diff)
use vanilla javascript to get the providers json
Diffstat (limited to 'page-providers.php')
-rw-r--r--page-providers.php39
1 files changed, 28 insertions, 11 deletions
diff --git a/page-providers.php b/page-providers.php
index b977210e..c912454b 100644
--- a/page-providers.php
+++ b/page-providers.php
@@ -128,17 +128,34 @@
html: filteredItems.join("")
}).appendTo('#providers');
}
- $.getJSON('<?php echo get_template_directory_uri() ?>/assets/providers.json', function (data) {
- items = data;
- shuffle(items);
- filterItems(selectedCountryCode, filterFreePlans, filterHosting);
- $.each(countries, function (key, countryCode) {
- $('#countryPicker').append($('<option/>', {
- value: countryCode,
- html: countryCode
- }));
- });
- });
+
+ var request = new XMLHttpRequest();
+ request.open('GET', '<?php echo get_template_directory_uri() ?>/assets/providers.json', true);
+
+ request.onload = function() {
+ if (request.status >= 200 && request.status < 400) {
+ items = JSON.parse(request.responseText);
+
+ shuffle(items);
+ filterItems(selectedCountryCode, filterFreePlans, filterHosting);
+
+ $.each(countries, function (key, countryCode) {
+ $('#countryPicker').append($('<option/>', {
+ value: countryCode,
+ html: countryCode
+ }));
+ });
+ } else {
+ // We reached our target server, but it returned an error
+
+ }
+ };
+
+ request.onerror = function() {
+ // There was a connection error of some sort
+ };
+ request.send();
+
$('#countryPicker').change(function () {
selectedCountryCode = $(this).find("option:selected").attr('value');
filterItems(selectedCountryCode, filterFreePlans, filterHosting);