Answer the question
In order to leave comments, you need to log in
Authorization form. Where is the mistake?
Good afternoon. I am writing my AJAX form on Bitrix. But I can't understand what the error is, why when you click on the "Order a call" button, for some reason nothing happens.
In footer.php I created the markup for the form itself.
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Форма обратного звонка</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="form-callback" action="ajax/callback.php">
<div class="form-group">
<label for="recipient-name" class="col-form-label">Имя:</label>
<input type="text" class="form-control" name="name">
</div>
<div class="form-group">
<label for="message-text" class="col-form-label">Телефон:</label>
<input type="text" class="form-control" name="phone">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<input class="btn btn-primary" type="submit" name="submit" value="Заказать звонок">
</div>
</div>
</div>
</div>
$(document).ready(function(){
$('#form-callback').on('submit', function(e) {
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serialize(),
dataType: 'json',
success: function(result){
if(result.status == 'success') {
$('#form-callback').html('<p class="alert alert-success">'+result.message+'</p>');
}
if (result.status == 'error') {
$('#form-callback .info-box').html('<p class="alert alert-danger">'+result.message+'</p>');
}
}
});
e.preventDefault();
return false;
})
});
Answer the question
In order to leave comments, you need to log in
F12 Zhamk, then submit Zhamk and look in the console, then in the Network tab - what's going on. What goes, what goes, what comes.
PS Why are you opening and closing PHP tags so many times???
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question