1

I am using the fine-uploader to allow multiple file uploads. The files are uploaded 1 by 1 by the fine-uploader library, and on the 'complete' event, which fires every time a file has uploaded successfully, I call a function that calls a web service and makes some updates to my database.

Potentially a user could update 100, or a 1000 files at a time.

My question is do i need to do anything specific to the JavaScript or Web services so that repeated requests do not cause a problem. I know that the $.ajax function is asynchronous by default, is this enough to ensure that problems don't occur?

2
  • Note that you will never have 100 or 1000 files uploading at once. By default, Fine Uploader only sends 3 files at a time. Even if you remove or change this limit, browsers natively limit the number of concurrent HTTP requests per endpoint host/domain. Also note that there is nothing magical about $.ajax - it just delegates to XMLHttpRequest which sends all requests asynchronously by default. It's not clear what "problems" you are worried about. If you can elaborate, perhaps you can get some more specific answers. Commented Feb 20, 2015 at 16:01
  • The problems I am worried about are general, such as the uploader crashing or becoming unresponsive. Commented Feb 23, 2015 at 8:21

1 Answer 1

2

You can call $.ajax as many times as you need to. jQuery will handle it just fine.

Also, is there a way you can update your database from the server-side at the time the file is uploaded? This way you would just have a single call to the server, thus greatly speeding up the entire file upload process since 1 call is much faster than 2.

Sign up to request clarification or add additional context in comments.

4 Comments

I would caution you from calling $.ajax as many times as you need to. Since browsers limit the number of concurrent requests per endpoint, you run the risk of holding up other requests elsewhere on the page.
@RayNicholus, correct you'll want to limit the number of concurrent requests to the same server. However, DavidB is talking about making these requests 1 at a time, so it shouldn't be a problem given there isn't anything else on the page make many requests simultaneously.
If he's simply sending the request when Fine Uploader fires an onComplete event, then there is no guarantee that there will only be 1 request sent at a time. Also, we don't know anything about the rest of the page.
I could potentially combine the upload call and the database update together, my only real issue is that i am using a dedicated file handler and don't really want it to know about database connections etc. Thanks for the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.