简体   繁体   English

如何在从jquery动态生成和加载iframe时执行操作

[英]How to do an action when iframe is generated and loaded dynamically from jquery

I a developing a site where I am using grails as my backend and php as my frontend and datatypes returns as JSON and Jquery. 我正在开发一个网站,我使用grails作为我的后端和php作为我的前端和数据类型返回为JSON和Jquery。 The issue is when I submit my form to target an iframe its work fine and return true value but yes on submitting the from I generates the iframe using jquery 问题是,当我提交我的表单以定位iframe时,它的工作正常并返回真值,但是在提交from时我是使用jquery生成iframe

Now what I have to do is take value out of that iframe and used it in my parent webpage and also to reset the form after submitting and iframe loaded how can I achieve this and how can I use jquery events on this. 现在我要做的就是从iframe中获取值并在我的父网页中使用它,并在提交后重置表单并加载iframe如何实现这一点以及如何在此使用jquery事件。

What event should I use to generate effects on my page after the data is posted successfully and hidden iframe loaded successfully. 在成功发布数据并隐藏iframe成功加载后,我应该使用什么事件在我的页面上生成效果。

Searching around I found sound help on Stack Overflow, about how to access iFrame parent page using jQuery. 搜索我发现Stack Overflow的声音帮助,关于如何使用jQuery访问iFrame父页面。

window.parent.document

jQuery is a library on top of JavaScript, not a complete replacement for it. jQuery是一个基于JavaScript的库,而不是它的完全替代品。 You don't have to replace every last JavaScript expression with something involving $ . 您不必使用涉及$替换每个最后的JavaScript表达式。

To find in the parent of the iFrame use: 要在iFrame的父级中查找,请使用:

$('#parentPrice', window.parent.document).html();

how to access iFrame parent page using jquery? 如何使用jquery访问iFrame父页面?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM