我有一个PHP脚本,它加载一个函数,该函数使用Curl将自己登录到另一个网页以获取一些数据。此操作总共需要大约14秒,一些用户可能会变得不耐烦。我有一个忙碌的装载机来指示活动。
我在其他网站上看过这个,想知道我需要什么技术来实现以下内容:
如何在PHP函数运行时将少量通知消息发送回主站点,以便用户知道进度。
消息可以采用以下形式:
Logging in to website
Extracting data
Sorting data
Closing connection
答案 0 :(得分:1)
You can do it using ajax, do the following.
1) Keep your curl code in the seperate php file.
2) While click the button, using js or jquery call that php file using ajax.
3) Before ajax return the reponse, you can display the div with your message, once you
got response, you can hide the div.