81,092
社区成员
发帖
与我相关
我的任务
分享
$.ajax({
cache : false,
type : "POST",
// async : false, // 设置为同步,等到返回结果再继续
url : "/testjson.action",
contentType : "application/json; charset=utf-8",
beforeSend : function(XMLHttpRequest) {
$('#foot').text("loading...");
},
success : function(result) {
//alert("result: "+result)
$('#foot').text("result: "+result);
},
});
<result type="json">
<param name="root">result</param>
</result>
public void testJson(){ //action
JSONObject json = new JSONObject();
json.put("id", "123");
json.put("name", "baidu bae");
result = json;
System.out.println("test json & json : "+result);
}
beforeSend : function(XMLHttpRequest) {
$('#foot').text("loading...");
},
success : function(result) {
alert("result: "+result)
$('#foot').text("result: "+result);
},
error : function(xhr, msg, e) {
alert("读取数据失败o(╯□╰)o")
}
是添加error么,不会执行这个public JSONObject testJson(){
JSONObject json = new JSONObject();
json.put("id", "123");
json.put("name", "baidu bae");
result = json;
System.out.println("test json & json : "+result);
return result;
}
结果是foot一直显示loading...