Re: [PHP] Multithreading in PHP
2009/3/17 Manoj Singh manojsingh2...@gmail.com: Hi Alpar, Thanks for reply. Actually the form is submitted through ajax request and the validation is checking on the server side. So if any error occurs on submission of form, then we are displaying the errors to the user. And is there is no error, then the submitted page started processing. So here client has to wait until the page process completed or not. What i want here if possible, after validating the user input server sends the thanks response to the client so that cleint doesn't has to wait, then the server starts the processing. Please suggest if it is possible. Regards, Manoj On Tue, Mar 17, 2009 at 7:01 PM, Alpár Török torokal...@gmail.com wrote: 2009/3/17 Manoj Singh manojsingh2...@gmail.com: Hi Guys, I am creating a page which submits the form through Ajax request the submitted page is sending the mails to n number of users. Now until the mail sends or the page process completed the end user has to wait. Is it possible that server sends the response to the client then start processing so that the client doesn't have to wait for the server response. Please suggest. Regards, Manoj Since you are using Ajax requests, which by their nature are asynchronous , your user won't have to wait. You can write some JS code to let him know that the request was sent, and just let the ajax call run in the background. On the server side make sure to ignore user abort, just in case the user navigates away. -- Alpar Torok Let me be more specific. it goes like this: front end: submit ajax, on server response check if the input didn't validate, or if the task finished, offer fedback on the server: ignore user intrerupt with ignore_user_abort(); and adjust max execution time validate the input send back errors if the the input doesn't validate (at this point the user won't have to wait for a long time) start the task that takes really long send a message that the task was done The user will either be on the page and get the message (if you want to show one) or navigated away by this time, but your processing is still done. -- Alpar Torok -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Multithreading in PHP
Hi Guys, I am creating a page which submits the form through Ajax request the submitted page is sending the mails to n number of users. Now until the mail sends or the page process completed the end user has to wait. Is it possible that server sends the response to the client then start processing so that the client doesn't have to wait for the server response. Please suggest. Regards, Manoj
Re: [PHP] Multithreading in PHP
Hi Alpar, Thanks for reply. Actually the form is submitted through ajax request and the validation is checking on the server side. So if any error occurs on submission of form, then we are displaying the errors to the user. And is there is no error, then the submitted page started processing. So here client has to wait until the page process completed or not. What i want here if possible, after validating the user input server sends the thanks response to the client so that cleint doesn't has to wait, then the server starts the processing. Please suggest if it is possible. Regards, Manoj On Tue, Mar 17, 2009 at 7:01 PM, Alpár Török torokal...@gmail.com wrote: 2009/3/17 Manoj Singh manojsingh2...@gmail.com: Hi Guys, I am creating a page which submits the form through Ajax request the submitted page is sending the mails to n number of users. Now until the mail sends or the page process completed the end user has to wait. Is it possible that server sends the response to the client then start processing so that the client doesn't have to wait for the server response. Please suggest. Regards, Manoj Since you are using Ajax requests, which by their nature are asynchronous , your user won't have to wait. You can write some JS code to let him know that the request was sent, and just let the ajax call run in the background. On the server side make sure to ignore user abort, just in case the user navigates away. -- Alpar Torok
Re: [PHP] Multithreading in PHP
2009/3/17 Manoj Singh manojsingh2...@gmail.com: Hi Guys, I am creating a page which submits the form through Ajax request the submitted page is sending the mails to n number of users. Now until the mail sends or the page process completed the end user has to wait. Is it possible that server sends the response to the client then start processing so that the client doesn't have to wait for the server response. Please suggest. Regards, Manoj Since you are using Ajax requests, which by their nature are asynchronous , your user won't have to wait. You can write some JS code to let him know that the request was sent, and just let the ajax call run in the background. On the server side make sure to ignore user abort, just in case the user navigates away. -- Alpar Torok -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multithreading in PHP
My suggestion is that you can start a second ajax as soon as the response about validating data is returned to process everithing you need and so your user wont wait until the process is finished. João Cândido Manoj Singh manojsingh2...@gmail.com escreveu na mensagem news:3859a530903170639m6c2af2b2s941446a31103c...@mail.gmail.com... Hi Alpar, Thanks for reply. Actually the form is submitted through ajax request and the validation is checking on the server side. So if any error occurs on submission of form, then we are displaying the errors to the user. And is there is no error, then the submitted page started processing. So here client has to wait until the page process completed or not. What i want here if possible, after validating the user input server sends the thanks response to the client so that cleint doesn't has to wait, then the server starts the processing. Please suggest if it is possible. Regards, Manoj On Tue, Mar 17, 2009 at 7:01 PM, Alpár Török torokal...@gmail.com wrote: 2009/3/17 Manoj Singh manojsingh2...@gmail.com: Hi Guys, I am creating a page which submits the form through Ajax request the submitted page is sending the mails to n number of users. Now until the mail sends or the page process completed the end user has to wait. Is it possible that server sends the response to the client then start processing so that the client doesn't have to wait for the server response. Please suggest. Regards, Manoj Since you are using Ajax requests, which by their nature are asynchronous , your user won't have to wait. You can write some JS code to let him know that the request was sent, and just let the ajax call run in the background. On the server side make sure to ignore user abort, just in case the user navigates away. -- Alpar Torok -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multithreading in PHP
Manoj Singh wrote: Hi Guys, I am creating a page which submits the form through Ajax request the submitted page is sending the mails to n number of users. Now until the mail sends or the page process completed the end user has to wait. Is it possible that server sends the response to the client then start processing so that the client doesn't have to wait for the server response. I can think of two ways to solve this apart from creating an Ajax request: 1. Queue the emails. Run a cron job to process the queue later. 2. Send the email after you flush the output. -- With warm regards, Sudheer. S Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, Personal: http://sudheer.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multithreading in PHP
Hi Sudheer, Can you please put more focus or sample code for the second option which you have suggested Send the email after you flush the output.. Regards, Manoj On Tue, Mar 17, 2009 at 7:28 PM, Sudheer Satyanarayana sudhee...@binaryvibes.co.in wrote: Manoj Singh wrote: Hi Guys, I am creating a page which submits the form through Ajax request the submitted page is sending the mails to n number of users. Now until the mail sends or the page process completed the end user has to wait. Is it possible that server sends the response to the client then start processing so that the client doesn't have to wait for the server response. I can think of two ways to solve this apart from creating an Ajax request: 1. Queue the emails. Run a cron job to process the queue later. 2. Send the email after you flush the output. -- With warm regards, Sudheer. S Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, Personal: http://sudheer.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multithreading in PHP
Manoj Singh wrote: Hi Sudheer, Can you please put more focus or sample code for the second option which you have suggested Send the email after you flush the output.. ?php //Code to send some output to user ... ... ... echo Email will be sent to you shortly; //Time to send email //Send all other output before this line ob_flush(); flush(); //Code to send email //echo Email sent; -- With warm regards, Sudheer. S Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, Personal: http://sudheer.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php