[英]Wait for a JS call to PHP to finish before continuing
我在主窗口的iFrame中有一张注册表。 当用户提交表单时,将调用PHP将数据插入数据库中。 完成此操作后,我将在父窗口中调用一个函数,以关闭iFrame。 不幸的是,iFrame在PHP完成之前就关闭了。 是否只有在PHP返回“ true”之后,才可以调用close iFrame函数?
这是函数:
<script type="text/javascript">
function submitForm() {
// Send the data to the server
document.getElementById("form1").submit();
// Call the 'close iframe' function in my parent window
parent.closeIFrame();
}
</script>
提交表单将刷新iframe。
因此,在从PHP返回的内容中,请在父窗口中调用该函数。
if(parent && parent.closeIFrame){
parent.closeIframe();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.