post方法回調json必須eval一下,而ajax方法作了默認處理了ajax
function haha() { json
jQuery.post("addComment!comment.action", post
function aa(data) { url
data = eval(data);//POST方法必加,ajax方法自動處理了 spa
alert(data[0].userId); io
alert(data[0].userName); function
}, "json" ); import
jQuery.ajax({ 方法
type:"post", im
url:"addComment!comment.action",
dataType:"json", success: function aa(data) {
alert(data[0].userId);
alert(data[0].userName);
} });
}