I'm trying to POST multiple AJAX data to update.php. This is my code at the moment:
$.ajax({
url:"update.php",
method:"POST",
data: $('#update_form').serialize(),
beforeSend:function(){
$('#update').val("Geupdate!");
},
success:function(data){
$('#update_form')[0].reset();
$('#add_data_Modal').modal('hide');
$('#employee_table').html(data);
}
});
However I also want to sent an ID within the data. This is the form that I'm using.
<form method="post" id="update_form">
<label>Notitie:</label>
<input type="text" name="name" id="' . $row["id"] . '" class="form-control" value='.$row["name"].' width="100%">
<br />
<input type="submit" name="update" id="update" value="Opslaan" class="btn btn-success" />
</form>
How can I combine data: $('#update_form').serialize()
and id="' . $row["id"] . '"
together?
I tried a few combinations but I can't find the correct answer. Here is what I've tried:
data: $('#update_form').serialize(), id: <?php echo $row["id"] ?>