jQuery $.get()

I run the following after each file is uploaded on a multi-file upload script. It works fine for all of the files minus the last. I am using jQuery 1.7.1.

$.get("save.php", { rand: rand, user:"<?php echo $userid; ?>", title: title});

If there are three files, it will run properly only the first two times. In FireBug, all the variables are fine, and it shows that it ran all three times, however the last time it ran it never actually loaded. In the ‘Timeline’ in Firebug it shows the spinning loading icon for the last process of save.php, along with no Status, or Size (this is in the Net tab). If I take this same URL and run it myself through my browser, it runs fine and loads instantly.

I have been stuck on this for nearly 3 hours and I hope someone here can help.

Could you please post the code that uploads the files as well as it’s hard to determine the issue without it and a link to a working version of the code.

I just tested this in Chrome and it ran fine, however Firefox is still not running the last instance properly.

To test, create a couple empty text documents and rename them to test1.mp4 and test2.mp4.

The reason why its not working is because the request is been ended before it can complete, indeed the AJAX request is been sent but because your not using an asynchronous request your if statement directly after is forcing the connection to close. A better method to use would be $.ajax() which allows you to determine whether you need an asynchronous request or not.

Awesome. I am now using $.ajax() with “async: false” and it works like a charm.