I have this javascript which uploads a selected file via the iframe. I need to be able to determine from the iframe whether the file was successfully uploaded or not. The problem is that it could be 3 seconds to upload the file or 30 seconds. The best method I can think of to trigger a function when the upload completes from within the iframe.... how would I target the main window from within the child iframe?
if (file === false) {
var newEl = that.reset(this);
//fix listener
triggerNotification('x', 'Unable to upload file, file type not accepted');
} else {
var id = Math.floor(Math.random()*101);
var form = jQuery(this).hide().after("<div class='upload'><div class='file'>"+file+"</div><div class='status'><img src='/image/progress-bar.gif'/></div></div><iframe id='"+id+"' name='"+id+"' src='about:blank' width='0' height='0' style='display: block;'></iframe>").parents('form');
form.attr('target', id).submit();
console.log(jQuery('iframe', form));
console.log(jQuery('iframe', form).contents());
console.log(jQuery('iframe', form).contents().find('body'));
console.log(jQuery('iframe', form).contents().find('body').html());
jQuery('input[type="button"]', form.parents('.popup-panel')).show();
triggerNotification('check', 'File has been uploaded');
//form.replaceWith("<a href='/image/icons/accept.png' target='_blank'><img src='/image/icons/accept.png' style='max-width: 120px;'/></a><br/><span class='faded'>(Click to view actual size)</span>");
}