jQuery(document).ready(function ($) { $('#update-spf-record-button').on('click', function (e) { e.preventDefault(); // const postId = $('#post_ID').val(); const postId = rlMailWarmerSpf.post_id; const host = $('#spf_host').val(); const action = $('#spf_action').val(); const allPolicy = $('#spf_all_policy').val(); const ttl = $('#spf_ttl').val(); $('#spf-update-result').html('

Updating SPF record...

'); $.ajax({ url: rlMailWarmerSpf.ajax_url, method: 'POST', data: { action: 'rl_mailwarmer_update_spf_record', post_id: postId, host: host, action_type: action, all_policy: allPolicy, ttl: ttl, security: rlMailWarmerSpf.nonce, }, success: function (response) { if (response.success) { $('#spf-update-result').html('

' + response.data + '

'); } else { $('#spf-update-result').html('

Error: ' + response.data + '

'); } }, error: function (xhr, status, error) { $('#spf-update-result').html('

AJAX Error: ' + error + '

'); }, }); }); });