im in deep trouble. im using ajax to submit a form in laravel. when i submit a form it does not submit correctly because each field of laravel does not have its assigned value. first field of laravel form is _token field, when i inspect my submitted data through chrome it shows _token field is empty and request assign my _token field to the very next field of form. in the same way each field dont have its corresponding value. i attached snapshot of chrome inspection please look into it. here is my code for a form.
<form id="add_car_2" class="s-submit clearfix" method="POST">
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="b-submit__main-element wow zoomInUp" data-wow-delay="0.3s">
<input type="checkbox" name="security_system" id="security_system" />
<label class="s-submitCheckLabel" for="security_system"><span class="fa fa-check"></span></label>
<label class="s-submitCheck" for="security_system">Security System</label>
</div>
<div class="b-submit__main-element wow zoomInUp" data-wow-delay="0.3s">
<input type="checkbox" name="air_bag" id="air_bag" />
<label class="s-submitCheckLabel" for="air_bag"><span class="fa fa-check"></span></label>
<label class="s-submitCheck" for="air_bag">Air Bag</label>
</div>
</div>
</form>
here is my ajax function to submit this form.
$("#add_car_2").submit(function(event) {
event.preventDefault();
var url=/cars/ + $('#car_id').data('carid');
$.ajax({
url: url,
type: 'POST',
data: new FormData(this),
processData: false,
success: function (data, status){
console.log(data);
console.log(status);
}
});
});
when i submit this form through ajax it shows failed to submit because each field of form does not have its correct value
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire