33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
/* Fusion WooDoo — Admin JS */
|
|
(function ($) {
|
|
'use strict';
|
|
|
|
$(function () {
|
|
const $btn = $('#fusion-woodoo-test-connection');
|
|
const $result = $('#fusion-woodoo-test-result');
|
|
|
|
$btn.on('click', function () {
|
|
$btn.prop('disabled', true).text('Testing…');
|
|
$result.hide().removeClass('success error');
|
|
|
|
$.post(fusionWooDooAdmin.ajaxUrl, {
|
|
action: 'fusion_woodoo_test_connection',
|
|
nonce: fusionWooDooAdmin.nonce,
|
|
})
|
|
.done(function (res) {
|
|
if (res.success) {
|
|
$result.addClass('success').text(res.data.message).show();
|
|
} else {
|
|
$result.addClass('error').text(res.data.message || 'Connection failed.').show();
|
|
}
|
|
})
|
|
.fail(function () {
|
|
$result.addClass('error').text('Request failed. Check your network connection.').show();
|
|
})
|
|
.always(function () {
|
|
$btn.prop('disabled', false).text('Test Connection');
|
|
});
|
|
});
|
|
});
|
|
}(jQuery));
|