doujian3401 2012-09-10 13:47
浏览 48
已采纳

HTML表单调用返回附件的PHP页面; 如何将“控件”返回到HTML页面?

All,

I have an HTML page that contains a form.

When the user completes the form and clicks "Submit" - the form posts the user's inputs to a PHP page.

That PHP page processes the inputs and returns the user's results as an attachment.

So far - everything works OK - the user clicks "Submit", the browser's progress bar starts to "spin", and after a few seconds, the attachment is downloaded.

However, in the browser - the user is still on the form page. That's OK with me.

So - here's my question. Ideally, when the user clicks "Submit" - I would like to update the form page to indicate that the "process" is in progress. E.g.,

  • disable the submit button to prevent redundant clicks
  • display a "downloading" message and a "spinner"-type graphic

Then, when the download is complete - I'd like to capture that event so that I could re-enable the submit button and remove the downloading message.

Is this possible?

Or - is my initial set-up just wrong? Is there a better way to do this? (That is - have a form that calls a PHP page, have the PHP page return an attachment, and then return control to the calling page?)

Thanks in advance for your advice and insight!

  • 写回答

4条回答 默认 最新

  • dsaj20411 2012-09-10 13:55
    关注

    Use javascript to open up the download in a new window. So don't return the download in the POST request, simply let the page reload and put some javascript on the page that will open up a new window that will call your PHP script that will download the file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法