Ext.Ajax.request

时间:2021-12-04 21:49:56
 function create(){
var itstate = $("#myselect").val();
Ext.Ajax.request({
url: '/servlet/AccountManagement?action=create',
params: {itstate: itstate },
method: 'POST',
success: function (response,data) {
var json = Ext.util.JSON.decode(response.responseText);
var msg = json.msg;
var flag = json.success;
Ext.MessageBox.alert(flag, msg);
/**跳转到新建账单页面**/
},
failure: function (response) {
var json = Ext.util.JSON.decode(response.responseText);
var msg = json.msg;
var flag = json.failure;
Ext.MessageBox.alert(flag, msg);
}
})
};

js发送ajax请求:

 JSONObject data = new JSONObject();
try{
data.put("success", "成功");
data.put("msg", "成功生成");
} catch (SQLException e) {
data.put("failure", "异常");
data.put("msg", "出现未知异常,账期创建失败");
e.printStackTrace();
}

后台响应