From: dongsheng Date: Sun, 16 Aug 2009 04:21:30 +0000 (+0000) Subject: "MDL-19118, simplify json parsing in commenting module" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=da964d222b45e3101555ada92850aa42c6738524;p=moodle.git "MDL-19118, simplify json parsing in commenting module" --- diff --git a/comment/comment.js b/comment/comment.js index 3005ac5d1f..0ee1edaa44 100644 --- a/comment/comment.js +++ b/comment/comment.js @@ -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; } diff --git a/lib/javascript-static.js b/lib/javascript-static.js index c4111a9e19..39584bcf58 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -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; }