형식 = 'submit'을 사용하지 말고 jQuery 이벤트를 일반 단추에 바인딩하고 ajax를 통해 양식을 처리하십시오. ajax를 통해 결과를 얻으면 대화 상자에 ajax 요청의 결과를 표시하거나 (PHP가 대화 상자에 메시지를 생성 함) 성공했는지 여부를 확인한 다음 적절한 조치를 취하는 조건을 지정할 수 있습니다.
다음은 in을 사용하는 예입니다. (코딩이 조금 엉성함)
$(document).ready(function() {
$('#submit').click(function() {
name = $('#name').val();
email = $('#email').val();
number = $('#number').val();
message = $('#message').val();
$.post("contact.php", //PHP file to send POST to
{ ajax: 'yes', name: name, email: email, number: number, message: message }, //POST fields to send
function(returned) { //What to do if the POST finishes. 'returned' is the value recieved back from the script.
if (returned == 'done') {
//PHP script returns the word 'Done'
alert('Submit successful');
});
} else {
alert('An error has occured');
}});});});
방금 업데이트를 보았습니다. :/내 대답을 nevermind :) –