#mailchimp-api-v3.0
#mailchimp-api-v3.0
Вопрос:
Я создал простую страницу и пытаюсь добавить форму регистрации MailChimp, используя скрипт из https://github.com/drewm/mailchimp-api/blob/master/README.md .
Я добавил приведенный ниже код в свой index.php и, кажется, это работает безукоризненно.
<form id="signup" action="index.html" method="get">
First Name: <input type="text" name="fname" id="fname" />
Last Name: <input type="text" name="lname" id="lname" />
email Address (required): <input type="email" name="email" id="email" />
<input type="submit" id="SendButton" name="submit" value="Submit" />
</form>
<div id="message"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('#signup').submit(function() {
$("#message").html("Adding your email address...");
$.ajax({
url: 'mailchimp/src/store-address.php', // proper url to your "store-address.php" file
type: 'POST', // <- IMPORTANT
data: $('#signup').serialize() 'amp;ajax=true',
success: function(msg) {
var message = $.parseJSON(msg),
result = '';
if (message.status === 'pending') { // success
result = 'Success! Please click the confirmation link that will be emailed to you shortly.';
} else { // error
result = 'Error: ' message.detail;
}
$('#message').html(result); // display the message
}
});
return false;
});
});
</script>
Однако я хотел бы удалить имя и фамилию в форме. Простое удаление строк в коде не сработает.
Думаю, это как-то связано с данными: $(‘#signup’).serialize() ‘amp;ajax=true’,. Но я не уверен. Кто-нибудь может указать мне правильное направление?
Заранее спасибо!