Guys this is my first question. I have a table which displays the students name and the input fields to enter their exam marks. The table header shows the subjects(its in a while loop) and has an input field to enter max marks for all of them. This max marks is updated thru Ajax. Its not happening properly. If we press submit first time, nothing will happen. If we press submit second time, it submits. If we press third time, it updates twice, if we press fourth time, it updates thrice (the success message shows thrice) Code -
<script>
$(document).ready(function(){
$("#maxmarks<?php echo "$m";?>").validate({
rules:{
maxmarks:{
number: true,
}
},
messages:{
maxmarks:{
number: "Please enter a valid marks",
}
},
submitHandler: function(form){
$("#maxmarks<?php echo "$m";?>").submit(function(){
$.ajax({
url : 'components/teacher/performance/maxupdate.php',
type : 'POST',
data : $("#maxmarks<?php echo "$m";?>").serialize(),
success : function(res){
$('#resultreturn').prepend(res);
}
});
return false;
});
}
});
});
</script>
The form has the same id as the script above. Can someone tell me what is the problem?