Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -23,29 +23,29 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
$('.block_newsletter form').on('submit', function () {
|
||||
var psemailsubscriptionForm = $(this);
|
||||
if (typeof psemailsubscription_subscription === 'undefined') {
|
||||
return true;
|
||||
}
|
||||
$('.block_newsletter_alert').remove();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: psemailsubscription_subscription,
|
||||
cache: false,
|
||||
data: $(this).serialize(),
|
||||
success: function (data) {
|
||||
if (data.nw_error) {
|
||||
psemailsubscriptionForm.prepend('<p class="alert alert-danger block_newsletter_alert">' + data.msg + '</p>');
|
||||
} else {
|
||||
psemailsubscriptionForm.prepend('<p class="alert alert-success block_newsletter_alert">' + data.msg + '</p>');
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$('.my_row.newsletter form').on('submit', function () {
|
||||
var psemailsubscriptionForm = $(this);
|
||||
if (typeof psemailsubscription_subscription === 'undefined') {
|
||||
return true;
|
||||
}
|
||||
$('.block_newsletter_alert').remove();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: psemailsubscription_subscription,
|
||||
cache: false,
|
||||
data: $(this).serialize(),
|
||||
success: function (data) {
|
||||
if (data.nw_error) {
|
||||
psemailsubscriptionForm.prepend('<p class="alert alert-danger block_newsletter_alert">' + data.msg + '</p>');
|
||||
} else {
|
||||
psemailsubscriptionForm.prepend('<p class="alert alert-success block_newsletter_alert">' + data.msg + '</p>');
|
||||
}
|
||||
},
|
||||
error: function (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user