양식이 있습니다. 내 JS 코드가 HTML 양식 아래에 있습니다.데이터를 성공적으로 전송할 경우 제출 버튼을 방지하려면 어떻게해야합니까?
경고가 나타나기를 원할 경우 (파일이있는 것처럼) 은 제출 확인 (페이지 새로 고침)을 막을 경우.
return true 또는 false를 사용할 수 있습니까? 내가 그들을 어디에 두어야할까요?
echo '<form id="gestion_form" method="post" action="#" enctype="multipart/form-data">';
....
echo '<button class="btn btn-green" style="margin-left: 10px; margin-bottom: 15px;" type="submit" name="Envoyer" id="envoyer">MODIFIER !</button>';
echo '</form>';
<script type="text/javascript">
$(function() {
$("#envoyer").click(function() {
$("#loader").show();
var file = $("#vignette").val();
var address = window.location.protocol + '//' + window.location.hostname;
$.ajax({
url: address + "/admin/img/" + file,
success: function(data){
alert("the file exist");
// Return false here or true ?
},
error: function(data){
// Return false here or true ?
}
});
});
});
</script>
이것은 내가 감사 한 것입니다. 아래를보십시오. – user3162341