douyi0902 2012-02-03 14:10
浏览 20
已采纳

在PHP脚本执行期间,在不同的点通过ajax显示不同的消息

I am using the following jquery file upload plugin to display progress bars when a user uploads mp3's.

http://blueimp.github.com/jQuery-File-Upload/

My server side script accepts the upload, converts the mp3 into a temporary wav file, generates a waveform image of the audio in png format then analyses the audio and stores the original mp3 filename, the png waveform, the analysed tempo and id3 information to the database.

All of this analysing and generating takes a few seconds to perform. From around 5 seconds for an average 5-6mb mp3 file up to maybe a minute for a large 50mb podcast.

Obviously the progress bar finishes when the file itself has finished uploading, however the php script continues to run until the file analysis is complete.

What I would like to be able to do is display a message such as 'analysing your song' perhaps with an animated gif once the file is uploaded, and then once the php script has completed, display a final 'completed' message.

Can anyone give me any advice on how best to approach this within the confines of the jQuery plugin mentioned above and standard PHP.

I am reluctant to post my code here as it is such a huge script. Therefore I will be content with more generic answers advising on the best approach to tackling this problem rather than detailed code modifications etc.

Many thanks

  • 写回答

2条回答 默认 最新

  • duagfgfn1981 2012-02-03 14:14
    关注

    Super-duper simple solution: Maybe have the script write log messages about its progress to a file, and then poll that file from AJAX?

    Script could delete the file when done, so when the AJAX eventually gets a 404, it could mean it's finished.

    The name of the file could be same as audio file with '.log' appended to it or something.

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

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料