| 1 |
(function ( $ ) { |
| 2 |
|
| 3 |
var request = window.location.search; |
| 4 |
request = request.replace( '?page=automatorwp_import_automation&', '' ); |
| 5 |
|
| 6 |
$.ajax({ |
| 7 |
url: ajaxurl, |
| 8 |
method: 'POST', |
| 9 |
data: { |
| 10 |
action: 'automatorwp_import_automation_from_url', |
| 11 |
nonce: automatorwp_import_automation.nonce, |
| 12 |
request: request, |
| 13 |
}, |
| 14 |
success: function( response ) { |
| 15 |
|
| 16 |
$('.automatorwp-import-automation-loader').hide(); |
| 17 |
$('.automatorwp-import-automation-icon-default').hide(); |
| 18 |
|
| 19 |
if( response.success ) { |
| 20 |
|
| 21 |
$('.automatorwp-import-automation-icon-success').show(); |
| 22 |
|
| 23 |
// Show the success message |
| 24 |
$('.automatorwp-import-automation-text') |
| 25 |
.addClass('automatorwp-import-automation-success') |
| 26 |
.html( response.data.message ); |
| 27 |
|
| 28 |
// Redirect to the new automation |
| 29 |
if( response.data.redirect_url !== undefined && response.data.redirect_url.length ) { |
| 30 |
window.location.href = response.data.redirect_url; |
| 31 |
} |
| 32 |
} else { |
| 33 |
|
| 34 |
$('.automatorwp-import-automation-icon-error').show(); |
| 35 |
|
| 36 |
// Show the error message |
| 37 |
$('.automatorwp-import-automation-text') |
| 38 |
.addClass('automatorwp-import-automation-error') |
| 39 |
.html( response.data ); |
| 40 |
} |
| 41 |
}, |
| 42 |
error: function( response ) { |
| 43 |
|
| 44 |
$('.automatorwp-import-automation-loader').hide(); |
| 45 |
$('.automatorwp-import-automation-icon-default').hide(); |
| 46 |
$('.automatorwp-import-automation-icon-error').show(); |
| 47 |
|
| 48 |
// Show the error message |
| 49 |
$('.automatorwp-import-automation-text') |
| 50 |
.addClass('automatorwp-import-automation-error') |
| 51 |
.html( response.data ); |
| 52 |
} |
| 53 |
}); |
| 54 |
|
| 55 |
})( jQuery ); |