"MDL-19118, simplify json parsing in commenting module"

This commit is contained in:
dongsheng 2009-08-16 04:21:30 +00:00
parent d25e2ca3f7
commit da964d222b
2 changed files with 4 additions and 16 deletions

View 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;
}

View 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;
}