datflo Posted July 31, 2014 Share Posted July 31, 2014 Hi, I've seen this done, and I thought it would be simple now that I am starting to understand ajax but I can't figure it out. I am using jQuery ajax via wordpress. I can click a button, call a php function and use the value returned from php to populate the textbox. Ok, great! but I want to run a rather lengthy procedure, and while it's running I would like it to record it's status in a multi-line text box as sort of a debugger ( and to pass the time while waiting ) How can I accomplish this? I've googled but I must not be using the correct words to search. Quote Link to comment https://forums.phpfreaks.com/topic/290212-jquery-update-textbox-with-progress-of-php-function/ Share on other sites More sharing options...
SergeiSS Posted July 31, 2014 Share Posted July 31, 2014 (edited) but I want to run a rather lengthy procedure, and while it's running I would like it to record it's status in a multi-line text box as sort of a debugger ( and to pass the time while waiting ) How can I accomplish this? I also don't know how to ask google about this task But I can direct you, I give you an algorithm. 1. You need daemon at your server. It could be PHP daemon. 2. This daemon must receive your request to start that lengthy procedure and start it. 3. Daemon answers to browser that it has started your task. 4. Your JS script will periodically ask (via AJAX) that daemon about the state of the task. 5. While in process it returns one state, when finished it returns another state. You may use ajax or WebSocket to connect JS script and server. The second one, I think, is preferrable for this task, because server can send to the browser any information without additional requests. Edited July 31, 2014 by SergeiSS Quote Link to comment https://forums.phpfreaks.com/topic/290212-jquery-update-textbox-with-progress-of-php-function/#findComment-1486571 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.