<form id="add_car_2" class="s-submit clearfix" method="POST">
{{method_field('patch')}}
<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>
这是我提交此表单的ajax函数。
$("#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);
}
});
});
答案 0 :(得分:0)
<form id="add_car_2" class="s-submit clearfix" method="POST">
{{csrf_field()}}
<input type="hidden" name="_method" value="patch">
<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>