I'm using standard jQuery Ajax to update values in the database and reflect the result in an output. This repetition seems like bad practice and I don't know enough about jQuery to consolidate this correctly.
jQuery
$("#vendorticket").change(function() { //Input/Select tag
var output = ("#vendorticket-result");
$.ajax({
url: 'includes/view.func.php', // Updating database based on specified row id, column, and value
type: 'post',
data: {
vendorticket: $(this).val(),
column: 'vendorticket',
id: 15
},
success: function(result) {
$(output).html(result); //Output span either "Saved" or "Save Failed"
}
});
});
//Rinse & Repeat...
$("#priority").change(function() {
var output = ("#priority-result");
$.ajax({
url: 'includes/view.func.php',
type: 'post',
data: {
priority: $(this).val(),
column: 'priority',
id: 15
},
success: function(result) {
$(output).html(result);
}
});
});
$("#assignedto").change(function() {
var output = ("#assignedto-result");
$.ajax({
url: 'includes/view.func.php',
type: 'post',
data: {
assignedto: $(this).val(),
column: 'assignedto',
id: 15 //
},
success: function(result) {
$(output).html(result);
}
});
});
});
HTML
<input type="text" id="assignedto" /><span id="assignedto-result"></span>
<input type="text" id="priority" /><span id="priority-result"></span>
<input type="text" id="vendorticket" /><span id="vendordicket-result"></span>