日期:2014-05-17  浏览次数:20745 次

用easyui的form组件发ajax得不到响应
大致代码如下:

$('#btn_sub').click(function() {
if ($('#type_form').form('validate')) {
$('#type_form').form('submit', {
url : flag == 'save' ? 'addcType.action' : 'updcType.action',
onSubmit : function() {

},
success : function(result) {
console.info(result);这个出不来

});
}
});

});


Action:
public String updcType() throws IOException {
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("html/text;charset=UTF-8");
try {
clientTypeService.updTypes(clientType);
String jsonSuccess = "{\"status\":\"ok\",\"message\":\"操作成功\"}";
System.out.println("Action已执行完毕");
response.getWriter().write(jsonSuccess);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
String jsonFailure = "{\"status\":\"failure\",\"message\":\"操作失败\"}";
response.getWriter().write(jsonFailure);
}
return null;
}


1、我的添加好好的,就是这个修改出问题,一模一样的代码。
2、我访问这个Action,居然给我弹出下载框,让我下载xxx.action文件,很奇怪!
3、通过firebug观察响应没有得到,提示这句话:“重新载入页面以获取源代码: http://localhost:8080/goods_management_system/basic/updcType.action
4、Action、业务类等等的代码均可正常执行。

总结:前台得不到响应结果。求大神!
Easyui struts2

------解决方案--------------------
contentType 为text/html 
------解决方案--------------------
改下配置