ajax交互struts返回json
ajax交互struts返回json
type="josn",就是返回json
type="redirect",就是返回页面
ajax一般是接受json,故result--》 type="json"
ajax接受HTML,故result——》type="redirect" 也可
struts-default 是sturts核心中的,json是struts-json-plugin.jar中的,这个插件包也继承了struts-default,只是拓展了struts返回json的要求
<package name="remindInfo" extends="json-default" namespace="/remind"> <action name="queryRemindInfo" class="remindInfoAction" method="queryRemindInfo"> <result type="json"> <param name="contentType">application/json</param> <param name="root">rspStr</param> </result> </action> <!-- zjq 2016-9-2 采用通配符优化配置 --> <action name="remindInfoAction_*" class="remindInfoAction" method="{1}"> <result type="json"> <param name="contentType">application/json</param> <param name="root">rspStr</param> </result> <result name="viewDetailRemindInfo">/itm/salefollow/remindInfoDetails.jsp</result> <result name="viewDetailWeiXinRemindInfo">/itm/salefollow/remindInfoWXDetails.jsp</result> <!-- <result name="updateRemindInfo">/itm/salefollow/saleFollowUp.jsp</result> --> </action> <action name="getMap" class="orderManageAction" method="getMap"> <result type="json"> <param name="contentType">application/json</param> <param name="root">result</param> </result> </action> </package>
// 微信交單提醒查询
public String queryWeixinRemind() {
if (null != agentid && !"".equals(agentid)) {
agentid = agentid.substring(1);
}
// 获取 下次联系时间的前10分钟
Date now = new Date(); //当前时间
Calendar calendar = Calendar.getInstance(); //得到日历
calendar.setTime(now);//把当前时间赋给日历
calendar.add(calendar.MINUTE, 10); //设置为后n分钟 负数为前n分钟
Date dBefore = calendar.getTime(); //得到后n分钟的时间
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
String strCurrentDate= formatter.format(dBefore);
String sql = "from RemindInfoEntity where agentid='" + agentid + "' and status='1' and remindtype='" + remindtype + "' and PresentationMethod='2'";
List<RemindInfoEntity> list = baseService.findObjects(new HQLQuery(sql));
if(list != null) {
rspStr = JsonUtils.bean2Json(list);
}
return SUCCESS;
}
//微信交單通知
function weixinRemind() {
$.ajax({
type: "POST",
url:"${pageContext.request.contextPath}/remind/remindInfoAction_queryWeixinRemind.action",
data: {
agentid: agentId,
remindtype:"2"
},
beforeSend: function() {},
success: function(data) {
var obj = eval("(" + data + ")");
$("#weixinRemindDiv").empty();
/*if(obj!=null && obj.length>0){
var viewInput="新进客户微信交单"+obj.length+"笔";
var confirmInput = "<a style=\"cursor:pointer;text-decoration:none;color:red\" onclick=\"window.frames['tabFrame'].loadTask('${ctx}/itm/salefollow/queryImportRemindTask.action?importRemind=3','重要提醒');\" " + ">查看详情</a>";
$("#weixinRemindDiv").append(viewInput);
$("#weixinRemindDiv").append(" ");
$("#weixinRemindDiv").append("</br>");
$("#weixinRemindDiv").append("</br>");
$("#weixinRemindDiv").append(confirmInput);
document.getElementById("weixinRemindId").style.display="block";
}*/
for(var i = 0 ; i < obj.length; i++) {
var viewInput="新进客户微信交单1笔";
var confirmInput = "<a style=\"cursor:pointer;text-decoration:none;color:red\" onclick=\"window.frames['tabFrame'].loadTask('${ctx}/itm/salefollow/queryImportRemindTask.action?importRemind=3','重要提醒');\" " + ">查看详情</a>";
$("#weixinRemindDiv").append(viewInput);
$("#weixinRemindDiv").append(" ");
$("#weixinRemindDiv").append("</br>");
$("#weixinRemindDiv").append("</br>");
$("#weixinRemindDiv").append(confirmInput);
$("#weixinRemindDiv").append("</br>");
$("#weixinRemindDiv").append("</br>");
document.getElementById("weixinRemindId").style.display="block";
/*if (obj[i]["reason"] != "") {
$("#weixinRemindDiv").append("</br>");
var content = "<span>"+ (i+1) + "." + obj[i]["reason"]+"</span>  ";
$("#weixinRemindDiv").append(content);
var orderno = obj[i]["orderno"];
var viewInput = "<a style=\"cursor:pointer;text-decoration:none;color:red\" onclick=\"window.frames['tabFrame'].loadTask('${ctx}/itm/salefollow/queryImportRemindTask.action?importRemind=3','重要提醒');\" " + ">处理</a>";
$("#weixinRemindDiv").append(viewInput);
$("#weixinRemindDiv").append(" ");
var ignoreInput = "<a" + " style='cursor:pointer;text-decoration:none;color:red'" + " onclick=ignoreRemind('" + orderno + "','3');" + ">忽略</a>";
$("#weixinRemindDiv").append(ignoreInput);
$("#weixinRemindDiv").append(" ");
var endRemindInput ="<a" + " style='cursor:pointer;text-decoration:none;color:red'" + " onclick=endRemind('" + orderno + "','3');" + ">结束提醒</a>";
$("#weixinRemindDiv").append(endRemindInput);
$("#weixinRemindDiv").append("</br>");
$("#weixinRemindDiv").append("</br>");
document.getElementById("weixinRemindId").style.display="block";
}*/
}
}
});
}
相关推荐
结束数据方法的参数,该如何定义?-- 集合为自定义实体类中的结合属性,有几个实体类,改变下标就行了。<input id="add" type="button" value="新增visitor&quo