duanmu8911 2014-07-17 09:42
浏览 19
已采纳

如何通过连续的AJAX调用来维护PHP对象

I am programming a php page for controlling a serial port using some in-screen-buttons. When I press a button, this sends some data through the serial port and it shows its response. All this is working OK.

Now, I need to listen continuously the serial port in order to receive data that I haven't ask for. I'm trying to do it with a timer in javascript, but every time I execute the PHP code through AJAX, serial port is restarted and its buffer is flushed. I need to pass the object that controls the serial port to the javascript code before finish the execution of the PHP code. And when pressing a button, I need to pass this object to the new PHP code.

How can I do this?

Thanks a lot

  • 写回答

4条回答 默认 最新

  • dsjq62428 2014-07-18 10:22
    关注

    I've found that this is imposible to be done: when the PHP code finish its execution, the serial port is closed automatically, so I lost all the data received untill I open the port again.

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

报告相同问题?