开发者

How to "hold" the page till submit responses with jquery

I was wondering if there's a simple way with Jquery to do something while the PHP process called by the forms gives a respond.

PS: I'm well aware of the ajax functions to send POST data and on success do something.

I'll explain I have a form on 1.php page that points to 2.php (just a script) that either redirects to the 1.php if something went wrong or to page 3.php if it's ok.

Want I wanna do with Jquery is show just a message with a gif loader (append a text below the submit button) while this submit process finishes (it could take up 10 secs since it resizes images). I'm asking a simple way because I don't want to pass each POST data through AJAX or validate data because this is all handled by the PHP page (2.php) by redirecting to pages.

I was able to do it the problem is that once you submit, since it returns true, everything on the original page stops. For example I put an animation to text "P开发者_Go百科rocessing, please wait..." with a gif which respectively won't continue through the all waiting time and won't show because if not saved in the cache some other time previously the submit will stop that process to download it, even if I preload it it won't animate for the same reason.

Basically what I need is to pass all the POST data through jquery ajax on submit (returning false to allow the new next to show!) and "let the process" continue on whatever response.

Thank you.


You can use a synchronous call instead of async for the jquery 'ajax' post, which will not return until the server's done processing. As part of the submit handler, pop up your "please wait, processing" message, and take it down once the response is received.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜