我有以下jQuery代码,我可以通过这个循环获取我的HTML元素。我想获取我的数据并通过AJAX将其存储到数据库中。我该怎么办?
$('#btnSubmit').on('click', function(){
for(var increment = 0; increment <= pos_inc; increment++) {
var text1 = $('#orders' + increment).val();
var text2 = $('#item_quan' + increment).val();
var text3 = $('#price_tot' + increment).val();
}
});
HTML
<table class="table dynamic_field">
<label>OR Number: <span id="sp_or"><?php echo $or_no; ?></span>
<br>
<br>
Sold To: <span id="sp_name"><?php echo $name; ?></span></label>
<thead>
<th>Items</th>
<th>Qty</th>
<th>Total</th>
</thead>
<tbody>
{{ csrf_field() }}
<!-- empty -->
</tbody>
</table>
<!-- hidden input-->
<input type="hidden" id="inc" value="<?php echo $inc; ?>">
<input type="hidden" id="or" name="or">
<input type="hidden" id="cus_name" name="cus_name">
<input type="hidden" id="total" name="total">
<!-- end of hidden input-->
<label>TOTAL: <span id="sp_tot"><?php echo $total; ?></span></label>
<br>
<label>CUSTOMER CHANGE: <?php echo $change; ?></label>
<br>
<br>
<br>
<a href="{{ url('use-pos') }}">
<button type="button" class="btn btn-default">Go Back</button>
</a>
<input type="button" class="btn btn-success" value="Complete Purchase" id="btnSubmit">
</form>
在我的控制器中:
public function DoAddSales(Request $request){
return $request->all();
}
答案 0 :(得分:0)
这是你的解决方案,
['\n',' ','a']