Answer the question
In order to leave comments, you need to log in
Why am I not getting data from the form?
The point is this. The form is not simple; it is added to me asynchronously after pressing the button. The idea is that I enter data, send it to the server and then write it all to the database.
But I don't get the form fields. I thought that the form is not visible because it is added by Ajax. I tried to somehow hook it from the body, but nothing came of it.
Here is the form itself:
<div class="box box-info" id="slide-form">
<div class="box-header">
<i class="fa fa-envelope"></i>
<h3 class="box-title">Quick Email</h3>
<!-- tools box -->
<div class="pull-right box-tools">
<button type="button" class="btn btn-info btn-sm close" title="Remove">
<i class="fa fa-times"></i></button>
</div>
<!-- /. tools -->
</div>
<div class="box-body">
<form action="/admin/main/add-slide" method="post" id="slider-submit-form">
<div class="form-group">
<input type="text" class="form-control" name="title" placeholder="Заголовок слайда">
</div>
<div class="form-group">
<input type="text" class="form-control" name="subtitle" placeholder="Подзаголовок слайда">
</div>
<div class="form-group">
<input type="text" class="form-control" name="price" placeholder="цена">
</div>
<div class="box-footer clearfix">
<button type="submit" class="pull-right btn btn-default slider_form_submit">Send
<i class="fa fa-arrow-circle-right"></i></button>
</div>
</form>
</div>
</div>
$('body#slide-form').on('submit',function () {
var data = $('form').serialize();
console.log(data);
});
$('form#slider-submit-form').on('submit',function () {
var data = $('form').serialize();
console.log(data);
});
$('.slider_form_submit').on('click',function () {
var data = $('form').serialize();
console.log(data);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question