Ajax Post文本输入

I have form

<input type="text" id="val_1" value="2">
<input type="text" id="val_2" value="1">
<input type="text" id="val_3" value="0">
<input type="text" id="val_4" value="5">

val_1: 1 is id in database i have field in database called value how to update data with value where id is 1,2,3,4 with ajax so val_1 is updated value (field in database where id = 1), val_2 updated value where id = 2

You can use data attribute.and get data attribute value.

<input type="text" id="val_1" data-id="1" value="2">
<input type="text" id="val_2" data-id="2" value="1">
<input type="text" id="val_3" data-id="3" value="0">
<input type="text" id="val_4" data-id="4" value="5">

Get form Id in jQuery and pass it to ajax data

var ids = [];
$('input[id^="val"]').each(function(input){
   var value = $(this).val();
   var id = $(this).data('id');
   alert('id: ' + id + ' value:' + value);
   ids.push(id);
});
// if You need all id then You can also get like below
alert('all ids'+ids);

Working Demo