Displaying success/failure messages from hidden iframe submit

走远了吗. 提交于 2019-12-12 19:05:58

问题


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.


回答1:


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

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).




回答2:


Enclose your iframe HTML in <div onload="javascript:window.parent.your_handler();"> ... </div>



来源:https://stackoverflow.com/questions/2914466/displaying-success-failure-messages-from-hidden-iframe-submit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!