I have a table of records. each table row has a submit button – when the submit button is clicked it makes a ajax request to the server. The first button works and request is sent to server. The next buttons do not work and the page refreshes each time when it should not. Any reason why this is happening ? I believe it is because i have an id on the button which references all records, but i am not sure.
Here is snippet of code:
$("#submitBtn").on('click', function(event) {
event.preventDefault();
var registerNo = $('#registerNo').val();
var date = $('#date').val();
var startTime = $('#startTime').val();
var endTime = $('#endTime').val();
var refNo = $('#refNo').val();
var attendance = $("#AttendanceValue option:selected").val();
var obj = {
attendance : attendance,
refNo : refNo,
registerNo : registerNo,
date : date,
startTime : startTime,
endTime : endTime
}
/*
$.ajax({
url: "process.asp",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(obj),
success: function (response) {
alert(JSON.stringify(response));
},
error: function(response) {
alert('There was an error: ' + response.responseText);
}
});
*/
console.log(obj);
});