I've got an iframe #uploadTarget which I'm using for image uploads:
function uploadImage(){
if ($('#imageUploader').val().length > 0){
$('#uploadingIndicator').show();
// set form params such that it uploads image
$('#uploadForm').attr("action", uploadUrl);
$('#uploadForm').attr("enctype", "multipart/form-data");
$('#uploadForm').attr("target", 'uploadTarget');
// submit for image upload
$('#uploadForm').submit();
resetFormAttributes();
//console.log($('#uploadTarget').contents().find('body').text());
} else {
resetFormAttributes();
$('#uploadForm').submit();
}
}
When image upload is done, the page inside the iframe executes javascript which calls doneUploading outside the iframe.
In the event where the file is too big or an error occurred and an error page is displayed in the iframe, the doneUpload function is not called.
Is it possible to have some sort of a callback function that triggers after $('#uploadForm').submit() completed (in which case I'll read the page for error responses)?
If not, how would I read error responses being returned inside the iframe?