У меня есть функция, которая должна вызываться при отправке формы для отправки ajax-запроса.Проблема в том, что, когда я пытаюсь отправить форму, я получаю следующую ошибку: «checkCustomerExists не определен». Кроме того, странно, что у меня есть промежуточный и рабочий сайты, и они в настоящее время идентичны, а промежуточный сайт не работает.проблема, но производственная площадка - та, у которой есть проблемы.Вот что у меня есть на обоих сайтах:
<script>
function checkCustomerExists(){
var phone = $('input[name=phone]').val();
var email = $('input[name=email]').val();
loadingModal();
if (phone !== '' && email !== '' && !checkedIfAccount){
var data = {
email,
phone
};
checkedIfAccount = true;
$.ajax({
url: "{{ shop.metafields.API.doesCustExist }}",
data: JSON.stringify(data),
method: "POST",
dataType: "json",
success: function(json){
if (json.exists){
if(!json.active){
var contactName;
var contactType;
if (json.email){
contactName = json.email;
contactType = 'email';
} else if(json.phone) {
contactName = json.phone;
contactType = 'phone number';
}
$('#error-message').html('Your account with the '+contactType+' <span>'+contactName+'</span> has not yet been activated. An email has been sent to you with an activation link to finish creating your account.');
$('#account-exists-modal').modal('show');
}
else if (json.email){
$('#error-message').html('There is an existing account with the registered email <span style="color: red">'+json.email+'</span>. Please Log In with the provided form.');
$('#account-exists-modal').modal('show');
} else if (json.phone){
$('#error-message').html('There is an existing account with the phone number <span style="color: red">'+json.phone.replace(/^\(?([0-9]{3})\)?(\s)?[-.●]?([0-9]{3})(\s)?[-.●]?([0-9]{4})$/, '($1) $3-$5')+'</span>. Please Log In with the provided form.');
$('#account-exists-modal').modal('show');
}
doesAcctExist = true;
} else {
addCustomeToPro();
}
});
checkedIfAccount = true;
}
}
</script>
<script>
var checkedIfAccount = false;
var doesAcctExist = false;
$('#add_prof').submit(function(e){
e.preventDefault();
var professions = [];
$('.prof_check:checkbox:checked').each(function(){
professions.push('Profession:' + $(this).val());
});
if (!validateForm(professions)) {
unloadButton();
return false;
}
checkCustomerExists();
});
</script>
Я не могу понять, почему один работает, а другой нет.Они оба в магазинах Shopify.Любая помощь приветствуется.