rl-warmup-plugin/js/test-ssh-connection.js

29 lines
1 KiB
JavaScript

jQuery(document).ready(function ($) {
$('#test-ssh-connection-button').on('click', function (e) {
e.preventDefault();
const postId = rlMailWarmerTestSSH.post_id;
$('#test-ssh-connection-result').html('<p>Testing connection...</p>');
$.ajax({
url: rlMailWarmerTestSSH.ajax_url,
method: 'POST',
data: {
action: 'rl_mailwarmer_test_ssh_connection',
post_id: postId,
security: rlMailWarmerTestSSH.nonce,
},
success: function (response) {
if (response.success) {
$('#test-ssh-connection-result').html('<p>Success: ' + response.data + '</p>');
} else {
$('#test-ssh-connection-result').html('<p>Error: ' + response.data + '</p>');
}
},
error: function (xhr, status, error) {
$('#test-ssh-connection-result').html('<p>AJAX Error: ' + error + '</p>');
},
});
});
});