From da964d222b45e3101555ada92850aa42c6738524 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Sun, 16 Aug 2009 04:21:30 +0000 Subject: [PATCH] "MDL-19118, simplify json parsing in commenting module" --- comment/comment.js | 18 +++--------------- lib/javascript-static.js | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) 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; } -- 2.39.5