jquery:将隐藏iframe的表单响应保存到变量

编程入门 行业动态 更新时间:2024-10-27 03:35:57
本文介绍了jquery:将隐藏iframe的表单响应保存到变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

heyho,

我有一个表格,我会在行动中发送给剧本。响应存储在预标记中的隐藏iframe中。我想用hquery将html-text答案存储到变量中。但问题是如何以及何时:-)! onsubmit是提前..你能帮忙吗?

i have a form which i send to a script on action. the response is stored to a hidden iframe in pre-tags. i want to store the html-text answer to a variable with jquery. but the question is how and when :-)! onsubmit is to early.. can you help?

<form id="search" action="xyzsearchurl" target="result"> <input type="text" name="qparam" /> <input type="submit" /> </form> <iframe id="result" name="result" src="#" style="display:none;"></iframe> $('#search').submit(function(){ alert($('#result pre').html()); });

任何想法如何获得文本形式预标记后得到回复?

any ideas how to get the Text form the pre tag AFTER get the response?

非常感谢

推荐答案

您可以从iframe注册onload事件然后阅读内容。 注意:这仅在从同一服务器加载帧时才有效(同源策略)

You can register the onload event from the iframe and then read the content. Note: this will only work if the frame is loaded from the same server (same origin policy)

$('#search').submit(function(){ //register load event of iframe... $('#result').load(function() { $("#result").contents().find("what you need..."); }); });

更多推荐

jquery:将隐藏iframe的表单响应保存到变量

本文发布于:2023-10-11 17:47:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1482394.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   变量   jquery   iframe

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!