나는 양식을 어디에서 해당 게시물을 변경하기로 결정보다 내가 <button name="submit" id="register" value="Register">Continue</button>
jquery submit이 작동하지 않는 이유는 무엇입니까?
와 함께 간단한 글을 사용하던 이전에 JQuery와 아약스 게시물 :
<script type="text/javascript">
$(document).ready(function() {
$("#register").click(function() {
if (!$("form").valid())
return false;
var isContinue = false;
$.ajax({
url: "/Validate",
type: "POST",
dataType: "text",
data: { recaptcha_challenge_field: $("input#recaptcha_challenge_field").val(), recaptcha_response_field: $("input#recaptcha_response_field").val() },
cache: false,
success: function (data, textStatus, xhr) {
isContinue = data === 'true';
},
error: function (xhr, st, err) {
alert("Sorry error occured, try again later.");
},
complete: function() {
alert(isContinue);//i could see that alert
if (isContinue) {
alert(isContinue); //i could see that alert
$("form").submit();
alert(isContinue); //i could see that alert
}
else {
return false;
}
}
});
});
});
</script>
<a class="button" id="register">Continue</a
그래서 capthca을 포함한 모든 검증은 내가 제출 클릭 할 때보다 전달 된 경우 버튼과 양식은 서버에 게시되지 않습니다. 나는 크롬과 오페라 network dev tools
와 요청을 확인하고 그들은 그 조치를 게재하지 않았지만 내가 자바 스크립트에 배치하는 경고와 함께 양식을 게시해야합니다.
그런 다음 테스트를 위해 다른 간단한 제출 버튼을 배치하고 어떤 이유로 든 양식을 게시했습니다. $("form").submit();
양식을 게시하고 싶지 않습니다.
일부 아이디어가있을 수 있습니까? 내가 simple post button
시도하지만 일이 내가 그렇게 찾고 또 다른 back button
: 가졌다 때
UPDATE
나는 ajax post button
을 주석 하였다
<button name="submit" class="cancel" id="back" value="Back">
때문에 문제는 정말 name="submit"
으로, 나는 그것을 제거하고 지금 일하고 있습니다. 문제가 바로 name="submit"
인데, 도움을 주셔서 감사합니다. 당신이 submit
라는 이름의 한 버튼을 form
요소에 submit
메서드를 재정의, 그래서 대신 form.submit
의 양식을 제출하는 기능되고 있기 때문에
JavaScript가 해제되어 있습니까? :) 그것은 당신에게 미친 소리 수도 있지만 당신의 웹 사이트의 필수적인 측면은 또한 자바 스크립트없이 작동하는지 확인해야한다고 생각합니다. 여기에는 양식 게시와 같은 기본 기능이 포함됩니다. – Bazzz