jQuery를 사용하여 하위 iframe에서 부모 창에 포함 된 양식을 제출하는 중입니다. 나는 다음과 같은 검증 기능이 자식 창에서 상위 창 (Ajax 제출)의 내용을 새로 고치지 않고 jQuery를 사용하여 상위 창에서 양식을 제출하는 방법
:<script type="text/javascript" src="templates/js/jquery.js"></script>
<script type="text/javascript" src="templates/js/jquery.validate.js"></script>
<script>
$(document).ready(function(){
$("#form_invoice_item").validate({
submitHandler: function (form) {
// Check if main invoice already saved
if ($('#invoice_id').val() == "") {
// Change target to processing iframe
try {
parent.$('#invoice_form').ajaxSubmit();
} catch(e) { //debug
alert ("Error:" + e);
}
} else {
alert ("Saving invoice " + $('#invoice_id').val() + ' items'); }
//form.submit(); //debug
}
});
});
</script>
<form method="post" id="form_invoice_item" name="form_invoice_item" action="index.php" target="invoice_items">
오류 parent.$('#invoice_form').ajaxSubmit();
발생이,
Error:TypeError: Object [object Object] has no method 'ajaxSubmit'
난 그냥 일반 자바 스크립트에 다음 코드를 사용하는 경우
입니다 분명히이 문제는 jQuery가 아니지만 작업이 완료된 것입니다. jQuery에서 어떻게합니까 :parent.document.getElementById('invoice_form').target='process';
parent.document.getElementById('invoice_form').submit();
parent.document.getElementById('invoice_form').target='';
display 속성이 hidden으로 설정된 프로세스라는 숨겨진 iframe이 있습니다.
$('#invoice_form',window.parent.document)
이것은 팝업 창을 나타내지 않으므로 'window .opener'는 관련이 없습니다. 이것은 iframe과 관련이 있기 때문에'window.document.parent'를 사용하여 부모를 참조하거나'$ (parent) '를 사용해야합니다 –
당신은 제 영웅입니다! 을 추가했습니다. 내 부분에 어리석은 실수. 고마워요 –
좋은 반갑습니다. 감사. 즐겨) –