【发布时间】:2011-09-30 18:40:52
【问题描述】:
我有一个正在通过 iframe 上传的文件。我现在可以在除 Opera 之外的所有浏览器中使用它。要首先提交表单,我有
$(document).ajaxComplete(function() {
$('.aboutContentImageForm').each(function() {
var $this = $(this);
$this.find('[type=file]').change(function() {
$this.submit();
});
});
});
然后为了捕获返回的帖子数据,我使用
$('.aboutContentImageForm').live('submit', function() {
$('#' + $this.attr('target')).load(function() {
var responseHtml = $(this).contents().find('body'),
response = responseHtml.html();
alert(response);
});
});
还有我的 HTML
<form action="ajax/about_content.php" method="post" enctype="multipart/form-data" class="aboutContentImageForm" target="form_image_upload_content_id_8">
<fieldset>
<input type="file" name="image_path" id="image_path_8">
</fieldset>
</form>
<iframe id="form_image_upload_content_id_8" name="form_image_upload_content_id_8"></iframe>
所以我的表单以 iframe 为目标,然后在 iframe 完成加载后,抓取返回的数据。
我可以确认 iframe 正在获取响应数据。点击提交后,我可以在框架中看到它。我只是无法捕获 iframe 接收所述数据的事件。这是.load() 的错误吗?
编辑
在load() 中添加alert 后,它看起来确实识别出此操作已完成,但他们为什么无法获得我的响应数据?
【问题讨论】:
-
看到有这个问题的完整页面真的很有趣:-o
标签: jquery browser iframe load opera