preventDefault()
및 return false
을 사용해도 My Ajax 양식이 두 번 제출됩니다.Ajax 양식을 두 번 제출하십시오
<script type="text/javascript">
$("#form_codes").submit(function(e) {
e.preventDefault();
$.ajax({
data: $('#form_codes').serialize(),
type: 'POST',
url: '{{url('save_code')}}',
success: function(msg) {
$('#product_codes > tbody:last-child').append('<tr><td>' + $('#code').val() + '</td><td>' + $('#description').val() + '</td></tr>');
$('#code').val('');
$('#description').val('');
},
error: function(msg) {
}
});
return false;
});
</script>
그리고 HTML에는'id = "form_codes"'로 된 양식이 1 개만 있습니까? – vaso123
어쩌면 그것은 당신의 클릭 이벤트와 관련이 있습니다 – Beginner
귀하의 질문에 문맥이 없습니다.하지만이 스 니펫을 두 번 호출하는 것 같아요. –