ajax跨域请求

6 篇文章 0 订阅
opurl = synInfo.action?proId=1&status="+status;
$.ajax({
type: "GET",
//async:'false',
contentType: "application/json; charset=utf-8",
url: opurl,
dataType:'jsonp',
jsonp:'jsoncallback',
//data: {"objId":objId,"sysName":sysName,"title":<%%>,"urlAddress":urlAddress,"objType":objType,"userEname":who,"jsoncallback":""},
success: function(data){
var flag = data.flag;
var msg = data.msg;
if(flag == 'T'){
alert("已经认领成功!");
}else{
alert("认领失败");
}
window.location.href="/aa.jsp";
},
error:function(XMLHttpRequest, textStatus, errorThrown){
alert(errorThrown);
}
});


public String jsonAttachList()
throws IOException
{
String jsoncallback = Struts2Utils.getRequest().getParameter("jsoncallback");
Struts2Utils.getResponse().setContentType("application/html;charset=UTF-8");
JSONObject jobj = new JSONObject();
String jb = StrUtil.doNull(jsoncallback);
String oi = StrUtil.doNull(this.objId);
String ot = StrUtil.doNull(this.objType);
if ((StrUtil.isEmptyWithTrim(oi)) || (StrUtil.isEmptyWithTrim(ot))) {
jobj.put("flag", "false");
jobj.put("msg", "缺少必要的参数!!");
if (StrUtil.isEmptyWithTrim(jb))
Struts2Utils.getResponse().getWriter().print(jobj.toString());
else {
Struts2Utils.getResponse().getWriter().print(jb + "(" + jobj.toString() + ")");
}
return null;
}
try {
List attachs = this.attachmentStoreManager.getAttachmentsByObjIT(oi, ot);
JSONArray jarr = new JSONArray();
for (Iterator iter = attachs.iterator(); iter.hasNext(); ) {
AttachmentStore atta = (AttachmentStore)iter.next();
AttaVO vo = copyAttaProp(atta);
jarr.add(JSONObject.fromObject(vo));
}
jobj.put("total", Integer.valueOf(jarr.size()));
jobj.put("flag", "true");
jobj.put("msg", "恭喜,数据查询成功!!");
jobj.put("rows", JSONArray.toArray(jarr));
logger.info("pic list get success!");
} catch (AttachmentStoreException e) {
jobj.put("flag", "false");
jobj.put("msg", "抱歉,附件查询异常!!");
logger.error(e);
} catch (AttachmentException e) {
jobj.put("flag", "false");
jobj.put("msg", "抱歉,附件查询异常!!");
logger.error(e);
}
if (StrUtil.isEmptyWithTrim(jb))
Struts2Utils.getResponse().getWriter().print(jobj.toString());
else {
Struts2Utils.getResponse().getWriter().print(jb + "(" + jobj.toString() + ")");
}
return null;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值