JohnT
3 Feb 2007, 8:04 AM
Play time over, and my boss is making me work. Darn it!
Anyways, I want to display a simple loading indicator in a DIV while file is uploading.
But the page appears to submit to itself, as well as my upload handler.
Any ideas?
<script type="text/javascript">
Upload = function(){
return{
init : function(){
/* Attach Listeners */
getEl("uploadForm").on("submit",Upload.sendFiles, Upload);
},
fileSuccess : function(o){
alert("Done");
},
fileFailure : function(o){
alert("FAILED");
},
sendFiles : function(){
/* Make sure there is at least one file */
// TO DO:
/* Begin Upload Transaction */
getEl("UploadStatus").setStyle("display","block");
getEl("StatusSpan1").setStyle("display","block");
var callback =
{
success: Upload.fileSuccess(o) ,
failure: Upload.filefailure(o)
}
// argument formId can be the id or name attribute value of the
// HTML form, or an HTML form object.
var formObject = getEl('uploadForm');
// the second argument is true to indicate file upload.
YAHOO.util.Connect.setForm(formObject, true);
var cObj = YAHOO.util.Connect.asyncRequest('POST', 'application_upload.php', callback);
}
};
}();
YAHOO.ext.EventManager.onDocumentReady(Upload.init, Upload, true);
</script>
Anyways, I want to display a simple loading indicator in a DIV while file is uploading.
But the page appears to submit to itself, as well as my upload handler.
Any ideas?
<script type="text/javascript">
Upload = function(){
return{
init : function(){
/* Attach Listeners */
getEl("uploadForm").on("submit",Upload.sendFiles, Upload);
},
fileSuccess : function(o){
alert("Done");
},
fileFailure : function(o){
alert("FAILED");
},
sendFiles : function(){
/* Make sure there is at least one file */
// TO DO:
/* Begin Upload Transaction */
getEl("UploadStatus").setStyle("display","block");
getEl("StatusSpan1").setStyle("display","block");
var callback =
{
success: Upload.fileSuccess(o) ,
failure: Upload.filefailure(o)
}
// argument formId can be the id or name attribute value of the
// HTML form, or an HTML form object.
var formObject = getEl('uploadForm');
// the second argument is true to indicate file upload.
YAHOO.util.Connect.setForm(formObject, true);
var cObj = YAHOO.util.Connect.asyncRequest('POST', 'application_upload.php', callback);
}
};
}();
YAHOO.ext.EventManager.onDocumentReady(Upload.init, Upload, true);
</script>