Jump to content

jQuery update textbox with progress of php function


datflo

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.