jquery:将隐藏iframe的表单响应保存到变量 [英] jquery: save form response from hidden iframe to variable
本文介绍了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="http://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的表单响应保存到变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文