]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-19118, simplify json parsing in commenting module"
authordongsheng <dongsheng>
Sun, 16 Aug 2009 04:21:30 +0000 (04:21 +0000)
committerdongsheng <dongsheng>
Sun, 16 Aug 2009 04:21:30 +0000 (04:21 +0000)
comment/comment.js
lib/javascript-static.js

index 3005ac5d1fc36bfd769cbd4d33619cece8182947..0ee1edaa44b9cba03f46f183905a305dba9b281d 100644 (file)
@@ -41,11 +41,7 @@ function get_comments(client_id, area, itemid, page) {
     }
     this.cb = {
         success: function(o) {
-            try {
-                var ret = YAHOO.lang.JSON.parse(o.responseText);
-            } catch(e) {
-                alert("JSON ERROR: "+o.responseText);
-            }
+            var ret = json_decode(o.responseText);
             if (!comment_check_response(ret)) {
                 return;
             }
@@ -68,11 +64,7 @@ function get_comments(client_id, area, itemid, page) {
 function post_comment(cid) {
     this.cb = {
         success: function(o) {
-            try {
-                var resp = YAHOO.lang.JSON.parse(o.responseText);
-            } catch(e) {
-                alert("JSON ERROR: "+o.responseText);
-            }
+            var resp = json_decode(o.responseText);
             if (!comment_check_response(resp)) {
                 return;
             }
@@ -120,11 +112,7 @@ function delete_comment(client_id, comment_id) {
     }
     this.cb = {
         success: function(o) {
-            try {
-                var resp = YAHOO.lang.JSON.parse(o.responseText);
-            } catch(e) {
-                alert("JSON ERROR: "+o.responseText);
-            }
+            var resp = json_decode(o.responseText);
             if (!comment_check_response(resp)) {
                 return;
             }
index c4111a9e1929e10c7c503f6c5cc7f9d6e30f248f..39584bcf58b41ba5af438a67819700979bbd2bbe 100644 (file)
@@ -1136,7 +1136,7 @@ function json_decode(json) {
     try {
         var obj = YAHOO.lang.JSON.parse(json);
     } catch (e) {
-        alert(e.toString());
+        alert(e.toString() + "\n" + stripHTML(json));
     }
     return obj;
 }