<form action="请求地址" enctype="multipart/form-data" method="post" target="cUploadWin_frame" id="cUploadWin_form">
<iframe id="cUploadWin_frame" name="cUploadWin_frame" style="display:none;"></iframe>
<input type = "file" id="file" name="file"></input>
</form>
用form表单提交请求,并且用iframe模拟ajax回调
action方法接收到请求并处理完请求,
注意return 返回值为null
this.getResponse().getWriter().print("<script>window.parent.productCallBack(1);</script>");
以调用js方法为回调让iframe
<iframe id="cUploadWin_frame" name="cUploadWin_frame" style="display:none;"></iframe>
<input type = "file" id="file" name="file"></input>
</form>
用form表单提交请求,并且用iframe模拟ajax回调
action方法接收到请求并处理完请求,
注意return 返回值为null
this.getResponse().getWriter().print("<script>window.parent.productCallBack(1);</script>");
以调用js方法为回调让iframe
本文介绍了一种通过HTML表单结合iframe元素实现文件上传的方法,该方法模拟了Ajax异步请求的效果,允许在不刷新页面的情况下上传文件,并通过调用JavaScript回调函数处理上传结果。
854

被折叠的 条评论
为什么被折叠?



