rl-warmup-plugin/js/admin-check-domain-health.js

35 lines
1.4 KiB
JavaScript

jQuery(document).ready(function ($) {
// console.log("Loaded check-domain-health.js");
$('#check-domain-health-button').on('click', function (e) {
e.preventDefault();
//var postId = $('#post_ID').val(); // Get the current post ID
var postData = {
action: 'rl_mailwarmer_check_domain_health',
post_id: rlMailWarmer.post_id,
security: rlMailWarmer.nonce,
};
// console.log("AJAX URL: " + rlMailWarmer.ajax_url);
// console.log("Post Action: " + postData.action);
// console.log("Post postId: " + postData.post_id);
// console.log("Post security: " + postData.security);
$('#domain-health-result').html('<p>Checking domain health...</p>');
$.ajax({
url: rlMailWarmer.ajax_url,
type: 'POST',
data: postData,
success: function (response) {
if (response.success) {
$('#domain-health-result').html('<p>Report saved successfully. Post ID: ' + response.data + '</p>');
} else {
$('#domain-health-result').html('<p>Error: ' + response.data + '</p>');
}
},
error: function (xhr, status, error) {
$('#domain-health-result').html('<p>AJAX Error: ' + error + '</p>');
},
});
});
});