Displaying success/failure messages from hidden if

2019-07-11 21:08发布

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.

2条回答
Melony?
2楼-- · 2019-07-11 21:23

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

查看更多
混吃等死
3楼-- · 2019-07-11 21:36

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

查看更多
登录 后发表回答