| 1 |
jQuery(document).ready(function ($) { |
| 2 |
var $container = $('#abj404-gsc-deferred-content'); |
| 3 |
if ($container.length === 0) { |
| 4 |
return; |
| 5 |
} |
| 6 |
if ($container.attr('data-deferred-load') !== '1') { |
| 7 |
return; |
| 8 |
} |
| 9 |
|
| 10 |
var action = $container.attr('data-ajax-action') || 'abj404_load_gsc_section'; |
| 11 |
var nonce = $container.attr('data-ajax-nonce') || ''; |
| 12 |
|
| 13 |
$.ajax({ |
| 14 |
url: window.ajaxurl || 'admin-ajax.php', |
| 15 |
type: 'POST', |
| 16 |
dataType: 'json', |
| 17 |
timeout: 15000, |
| 18 |
data: { |
| 19 |
action: action, |
| 20 |
nonce: nonce |
| 21 |
}, |
| 22 |
success: function (response) { |
| 23 |
if (response && response.success && response.data && typeof response.data.html === 'string') { |
| 24 |
$container.html(response.data.html); |
| 25 |
$container.attr('data-deferred-load', '0'); |
| 26 |
return; |
| 27 |
} |
| 28 |
|
| 29 |
var message = 'Unable to load Google Search Console section.'; |
| 30 |
if (response && response.data && response.data.message) { |
| 31 |
message = String(response.data.message); |
| 32 |
} |
| 33 |
$container.html('<p class="abj404-form-help">' + $('<div>').text(message).html() + '</p>'); |
| 34 |
$container.attr('data-deferred-load', '0'); |
| 35 |
}, |
| 36 |
error: function (jqXHR, textStatus) { |
| 37 |
if (typeof console !== 'undefined' && console.log) { |
| 38 |
console.log('404 Solution: GSC section load failed (' + textStatus + ')'); |
| 39 |
} |
| 40 |
$container.html('<p class="abj404-form-help">Unable to load Google Search Console section.</p>'); |
| 41 |
$container.attr('data-deferred-load', '0'); |
| 42 |
} |
| 43 |
}); |
| 44 |
}); |
| 45 |
|