后台
String json = "{success:";
if (b)
json += "true";
else
json += "false";
json += "}";
try {
response.getWriter().write(json);
} catch (IOException e) {
e.printStackTrace();
}
前台
[code="java"]
_login.getForm().submit({
success : function(json) {
Ext.Msg.alert("成功提示", "大家好啊,成功了!");
[/code]
如何 获取 json 里传过来的值 用 var data=eval("("+json+")"); 在 data.result 获取不到
你试试后台用
[code="java"]response.getWriter().print(json);
[/code]
前台
[code="java"]success : function(response,options)
{
var data = Ext.decode(response.responseText);
if(data.success)
{
//成功
}
else
{
//失败
}
}[/code]
[code="js"]
success : function(form,action)
{
var data = action.result;
alert(data.success);
}
[/code]