Author: jmorliaguet
Date: Sun Mar 19 19:32:20 2006
New Revision: 2668

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
Log:

- make sure we get a response with text/x-json as content type before parsing
  it.



Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Sun Mar 19 
19:32:20 2006
@@ -607,8 +607,7 @@
       this.views.entries().each(function(v) {
         var view = CPSSkins.getViewById(v);
         view.request(target.href);
-      })
-
+      });
       Event.stop(e);
     }
   }
@@ -1571,8 +1570,11 @@
     if (!url) return;
     var options = {
       onComplete: function(req) {
-        var data = JSON.parse(req.responseText);
-        storage.write(data);
+        var content_type = req.getResponseHeader('content-type');
+        if (content_type.match(/^text\/x-json/)) {
+          var data = JSON.parse(req.responseText);
+          storage.write(data);
+        }
       }
     }
     var parts = url.split('?');
@@ -1936,6 +1938,11 @@
         if (disp && disp.match(/^attachment/)) {
           window.location = url;
         }
+        var content_type = req.getResponseHeader('content-type');
+        if (content_type.match(/^text\/x-json/)) {
+          var data = JSON.parse(req.responseText);
+          view.model.writeData(data);
+        }
         view.refresh();
       }
     };
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to