简体   繁体   中英

persistent php connection?

Is it possible to have a php script pause at a certain point wait for an ajax response, then continue executing?

If not, what is the most appropriate way to store the current state of a script (all defined variables ect) untill it in invoked again?

Making it wait for an ajax response which could never come sounds like a very bad plan (apart from being impossible due to the nature of http as a stateless protocol).

What's wrong with using session to persist user data (you can store objects in the session)? It won't serialize the whole state automagically though.

Not how php works, or ajax really either. Each request is independent. You can use a session.

我认为您正在寻找Comet 链接文本 -这是反向Ajax的一种形式,它无限期地保持连接的打开状态-尽管我不认为您会拥有一个PHP脚本来等待它...

If you want to get in your php script response that you would normally access via ajax then just use curl functions. Curl will wait for the response to arrive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM