Roo/form/ComboBoxArray.js
[roojs1] / Roo / form / Action.js
index e58af43..4aa2160 100644 (file)
@@ -67,6 +67,7 @@ Roo.form.Action.prototype = {
 
     // default connection failure
     failure : function(response){
+        
         this.response = response;
         this.failureType = Roo.form.Action.CONNECT_FAILURE;
         this.form.afterAction(this, false);
@@ -133,9 +134,12 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
     haveProgress : false,
     uploadComplete : false,
     
-    // uploadPrograss indicator.
+    // uploadProgress indicator.
     uploadProgress : function()
     {
+        if (!this.form.progressUrl) {
+            return;
+        }
         
         if (!this.haveProgress) {
             Roo.MessageBox.progress("Uploading", "Uploading");
@@ -156,8 +160,23 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
                 id : uid
             },
             method: 'GET',
-            success : function(data){
+            success : function(req){
                //console.log(data);
+                var rdata = false;
+                var edata;
+                try  {
+                   rdata = Roo.decode(req.responseText)
+                } catch (e) {
+                    Roo.log("Invalid data from server..");
+                    Roo.log(edata);
+                    return;
+                }
+                if (!rdata || !rdata.success) {
+                    Roo.log(rdata);
+                    return;
+                }
+                var data = rdata.data;
+                
                 if (this.uploadComplete) {
                    Roo.MessageBox.hide();
                    return;
@@ -170,11 +189,12 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
                 }
                 this.uploadProgress.defer(2000,this);
             },
-            scope : this,
-           failure: function(data) {
+       
+            failure: function(data) {
                 Roo.log('progress url failed ');
                 Roo.log(data);
-           }
+            },
+            scope : this
         });
            
     },
@@ -189,13 +209,12 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
         var method = this.getMethod();
         var isPost = method == 'POST';
         if(o.clientValidation === false || this.form.isValid()){
+            
             if (this.form.progressUrl) {
-           
-                this.findField('UPLOAD_IDENTIFIER').setValue(
+                this.form.findField('UPLOAD_IDENTIFIER').setValue(
                     (new Date() * 1) + '' + Math.random());
                     
-            }
-            
+            } 
             
             
             Roo.Ajax.request(Roo.apply(this.createCallback(), {
@@ -221,6 +240,7 @@ Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
             Roo.MessageBox.hide();
         }
         
+        
         var result = this.processResponse(response);
         if(result === true || result.success){
             this.form.afterAction(this, true);
@@ -287,6 +307,7 @@ Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
     type : 'load',
 
     run : function(){
+        
         Roo.Ajax.request(Roo.apply(
                 this.createCallback(), {
                     method:this.getMethod(),
@@ -296,6 +317,7 @@ Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
     },
 
     success : function(response){
+        
         var result = this.processResponse(response);
         if(result === true || !result.success || !result.data){
             this.failureType = Roo.form.Action.LOAD_FAILURE;