加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

(1) $.ajax请求后台,后台总结错误信息后write到前提,chrome 遨

发布时间:2020-12-16 02:11:04 所属栏目:百科 来源:网络整理
导读:/my-test/src/main/webapp/Template/visit/infoInputDB.jsp //$.ajax提交 $.ajax({ type : "POST", url : bathPath + "/OperateDB/test/migration", data : { st1DtYuan : $("#st1DtYuan").val(), et1DtYuan : $("#et1DtYuan").val(), tbName2 : $("#tbName2
/my-test/src/main/webapp/Template/visit/infoInputDB.jsp
//$.ajax提交
$.ajax({
type : "POST",
url : bathPath + "/OperateDB/test/migration",
data : {
st1DtYuan : $("#st1DtYuan").val(),
et1DtYuan : $("#et1DtYuan").val(),
tbName2 : $("#tbName2").val(),
tbCol2 : $("#tbCol2").val(),
st1DtMu : $("#st1DtMu").val(),
et1DtMu : $("#et1DtMu").val(),
params: params.toString()
},
success : function(data) {
alert(data);
$("#changeData").removeAttr("disabled");
},
error:function(data) {
$("#changeData").removeAttr("disabled");
},
dataType:'text'
});


//my-test/src/main/java/com/cntv/cn/controller/operateDb/OperateDBDataController.java
@ResponseBody
@RequestMapping(value = "/migration")
public void migration(String st1DtYuan,String et1DtYuan,String st1DtMu,String et1DtMu,String tbName2,String tbCol2,
HttpServletRequest request,HttpServletResponse response,
ModelMap model,String params) throws IOException{

PrintWriter pw = response.getWriter();
String result=null;

boolean b = timeOverlap(st1DtYuan,et1DtYuan,st1DtMu,et1DtMu);
if (b) {
result="源区间与目的区间时间存在重叠,请修改!";
}else{
//两个日期区间 之间的日期 保存在列表中
List listYuan = DateUtils.days(st1DtYuan.substring(0,10),et1DtYuan.substring(0,10));
List listMudi = DateUtils.days(st1DtMu.substring(0,et1DtMu.substring(0,10));
DbModel dbmodel = new DbModel(st1DtYuan,tbName2,tbCol2,et1DtMu,parseParamsStr(params),listYuan,listMudi);
try {
result = operateDBService.migration(dbmodel);
} catch (Exception e) {
e.printStackTrace();
}
}
pw.write(result);
}

//现象:chrome 遨游 正常。火狐弹出 [Object Xmldocument]。

//1
response.setContentType("text/plain")
//2
在 $.ajax中指定 指定返回类型
dataType:'text'

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读