This one works for me.
Here's my PHP:
<div id="pageContent">
<?php
while($row = mysqli_fetch_assoc($stmt)) {
?>
<br/>
<input id="vendorName_" name="vendorName_<?php echo $row["id"]; ?>" value='<?php echo $row["vendorName"]; ?>'>
<input id="owner_" name="owner_<?php echo $row["id"]; ?>" value='<?php echo $row["owner"]; ?>'>
<input id="city_" name="city_<?php echo $row["id"]; ?>" value='<?php echo $row["city"]; ?>'>
<button id="btn_update_<?php echo $row["id"]; ?>">Update</button>
<button id="btn_delete_<?php echo $row["id"]; ?>">Delete</button>
<?php
}
?>
</br></br>
<input id = "vendorName_new" value="">
<input id = "owner_new" value="">
<input id = "city_new" value="">
<button id = "addNewVendor" type="submit">+ New Vendor</button>
</div>
Here's my jQuery using AJAX:
$("#addNewVendor").click(function() {
alert();
$.ajax({
type: "POST",
url: "create.php",
data: {vendorName: $("#vendorName_new").val(), owner: $("#owner_new").val(), city: $("#city_new").val()},
success: function(){
$(this).hide();
$('div.success').fadeIn();
showUsers()
}
});
});