slash197
slash197

Reputation: 9034

PHP script not finishing its job

I have a web page where I am POSTing 2 images to a php script from a canvas through xmlhttprequest. If I wait for the 2 separate requests to finish everything is ok but if I navigate away from the page after the first one finished uploading the second one just doesn't do anything I guess it simply stops.

My questions is do I have to keep the page open until both uploads are finished? I thought if an xmlhttprequest is started it will finish no matter what, even if you close the browser.

Upvotes: 1

Views: 241

Answers (3)

pomeh
pomeh

Reputation: 4912

As said by symcbean, all XMLHttpRequest are bound to your current page. So if you change the page or if you close the tab or the browser, all currently running request will be aborted.

I thought if an xmlhttprequest is started it will finish no matter what, even if you close the browser.

Do you like if, when you close an application, it doesn't really close it and the application would still running on the computer ?

Upvotes: 0

ab_dev86
ab_dev86

Reputation: 1982

Well could it be that you go away from the page while you are still uploading the image? (if the image is quite big it could take a while to upload it completely) in that case you are stopping the upload and probably the page php that manage the end of the upload doesn't execute.

Upvotes: 0

symcbean
symcbean

Reputation: 48357

No - the xmlhttprequest is bound to the page you are currently on.

Add a callback to show the user when the process completes.

Upvotes: 1

Related Questions