Now if that isn’t a weird question, I don’t know what is.
But here is the problem: I have a function in my “onSelect” option that has to collect some data (through AJAX) and I have a function in my “onComplete” option that processes the just uploaded files based on the data “onSelect” collected.
However, with very small files, the “onSelect” hasn’t finished yet before the upload is complete and the “onComplete” fails because it lacks the necessary data. Bigger files work just fine.
So, I’m looking for a way to stall the upload of the file. To let it start only after the function in onSelect completed fetching the necessary data.
Any ideas?
Here is an example of the function that the onSelect triggers:
var foo = new Array();
function checkDB( event, queueID , fileObj )
{
$.post( ajax_folder + 'fetchData' ,
{
ref: "someValue"
} ,
function( data ){
foo[ queueID ] = data.result;
} ,
'json' );
return true;
}
I generally agree with Peter that you should try and tap into the events more elegantly. However, you can (and probably should) extract that code into a function and keep a flag that tells you if it’s been called before. Something like this:
Of course you could always check the length of foo instead of using a flag.