갖는 다음과 같은 형식으로 검증 한 후 양식을 제출합니다. 그러나 에서 으로 인 경우 resp이 확인되면 양식을 제출하지 않는 것 같습니다.는 jQuery를 통해 클릭
1
A
답변
0
당신은 당신이 폐쇄
$("#Login").submit(function(event) {
// main submit handling function starts here
...
$.post(url,data,function(resp){
// inner response handling function starts here
if(resp === " "){
console.log("Empty");
return; //This returns to jQuery internals somewhere inside $.post
} ...
},'json');
// stops form from submitting
event.preventDefault();
});
난 당신이 더 나은 시각을 얻을 수 있도록 의견의 몇 가지 추가가에 대해 혼동하는 것 무엇 if
조건
$("#Login").submit(function (event) {
var form = this;
var url = 'ajax/';
var data = {};
$('input').each(function() {
data[$(this).attr('name')] = $(this).val();
});
$.post(url, data, function (resp) {
$("#formLoginErrorMessage").children().remove();
if (resp === " ") {
form.submit();
console.log("Empty");
return; // The form should submit
} else if (typeof resp === "object") {
console.log(resp);
} else {
$("#formLoginErrorMessage").addClass("alert-danger");
$("#formLoginErrorMessage").append("<li>" + resp + "</li>");
console.log(resp);
}
}, 'json');
event.preventDefault();
});
0
에 submit() 메소드를 호출 할 수 범위의.
먼저 클라이언트 측 유효성 검사에 의존해서는 안됩니다. 그것은 예외없이 추월 될 수 있습니다. 어떤 이유로이 방법을 사용하면 유효 범위가 전달되었는지 여부를 결정하기 위해 일부 외부 범위 변수를 사용할 수 있지만 실제로 양식을 제출하려면 return
대신 $form.submit()
을 사용해야합니다.
관련 문제
- 1. jquery를 통해 버튼을 클릭
- 2. jQuery를 통해 클릭 이벤트와 함께 span을 추가하십시오.
- 3. 는 jQuery를
- 4. 는 jQuery를 내가 클릭에 이미지를 저장주의 클릭
- 5. 는 jQuery를
- 6. Jquery를 통해 클릭 한 링크의 가치를 얻으시겠습니까?
- 7. jQuery를 통해 div에 클릭 가능한 링크
- 8. jQuery를 처리 클릭
- 9. 는 jQuery를
- 10. jQuery를 - 클릭
- 11. 는 jQuery를
- 12. 는 jQuery를
- 13. 는 jQuery를 Document.click
- 14. jQuery를 자동 클릭 문제
- 15. 는 jQuery를
- 16. 는 jQuery를
- 17. 는 jQuery를
- 18. 는 jQuery를
- 19. 는 jQuery를
- 20. 는 jQuery를
- 21. 는 jQuery를
- 22. 는 jQuery를
- 23. 는 jQuery를
- 24. 는 jQuery를
- 25. 는 jQuery를
- 26. 는 jQuery를
- 27. 는 jQuery를
- 28. 는 jQuery를
- 29. 는 jQuery를
- 30. 는 jQuery를
변경 ** this.submit(); ** to ** form.submit(); ** 변경 사항이 적용됩니다. – user3799263
및 ** ** return; ** 제거 할 필요는 없습니다. @php_nub_qq에게 감사드립니다. – user3799263