从隐藏的iframe显示成功/失败消息提交 [英] Displaying success/failure messages from hidden iframe submit

查看:365
本文介绍了从隐藏的iframe显示成功/失败消息提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是隐藏的iframe方法与文件上传字段提交表单。我想用JavaScript来显示一个消息返回页面上,我不知道如何做到这一点。如果这只是一个带有文本字段的形式我会做一个AJAX岗位和具有消息我会在我的回调函数,显示响应。我只是不知道如何完成与隐藏的iframe方法完成相同的任务,因为它是一个标准的表单提交。

I'm using the hidden iframe method to submit a form with a file upload field. I want to display a message back on the page using javascript and I'm not sure how to do this. If this was just a form with text fields I'd do an AJAX post and respond with a message I'd display in my callback function. I'm just not sure how to accomplish this same task with the hidden iframe method since it is a standard form post.

推荐答案

里面的iframe,当你的服务器在完成上传后回应,您可以包括一些onload事件的Javascript在那里引用帧。

Inside the iframe, when your server responds after finishing the upload, you can include some onload Javascript in there that references the parent frame.

另外,你可以附加一个onload监听到自己的iframe从父页中。如果添加此监听器IFRAME最初加载后,它不应该开火,直到下一个负载(这将是上传完成后)。

Alternatively, you could attach an onload listener to the iframe itself from within the parent page. If you add this listener after the iframe initially loads, it should not fire until the next load (which would be after the upload completes).

这篇关于从隐藏的iframe显示成功/失败消息提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆