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

Reply via email to