jquery跨域调用

jquery跨域调用实例:

js:

var receiveCode = { 
receive : function(){  
var gacId = $("input[name='gacId']").val();  
$.getJSON("receiveActiveCard.do?jsonpCallback=?",{gacId:gacId},function(data){     
$("#content").html('<span class="tipText">'+' '+'</span>');
if(data.error!=undefined){
alert(data.error);
}    
var isLog = data.loginState;
if(isLog == '0'){
alert('网页已过期');
window.location.reload();
}else{
if(data.receiveState!=null&&'1'==data.receiveState){       
$("#content").append('<span style="color:red">已经领取完毕!</span> ');
}else{
if(''!=data.activecardno){
$("#content").append('<p class="text"><span class="get_title">'+'卡号: '+data.activecardno+'</span></p>');
}
if(''!=data.activecardpass){         
$("#content").append('<p class="text"><span class="get_title">'+'密码:  '+data.activecardpass+'</span></p>');
}
}
}

});
   }          
}

action:

/******************************
 * 版权所有:顺网科技 保留所有权利
 * 创建日期: Apr 20, 2011 10:32:52 AM
 * 创建作者:hutaisi
 * 文件名称:
 * 版本: 1.0
 * 功能:
 * 最后修改时间:
 * 修改记录:
 ****************************************/

public class CardReceiveRecordAction extends ExpandAction {


private final Logger logger = LoggerFactory.getLogger(LoginAction.class);


private CardReceiveRecordBO cardReceiveRecordBO;


private Integer gacId;
        private String jsonpCallback;
        private String receiveValidateCode;

/**
* 直接领号
* @return
*/
public String  receiveActiveCard(){
PageStateInfo pageStateInfo = new PageStateInfo();
String outInfo = null;
if(gacId!=null){    
ActiveCard activeCard = cardReceiveRecordBO.receiveActiveCard("default", gacId);
if(activeCard!=null){
outInfo = activeCard.toJsObject().toString();
logger.info("默认用户领取新手卡");  
}else{ 
pageStateInfo.setReceiveState(Context.IS_RECEIVE);
outInfo = pageStateInfo.toJsObject().toString();
logger.info("激活卡:"+gacId+"已经领取完!");        
}        
}  
outMsg(jsonpCallback+"("+outInfo+")");    
return null;
}


public Integer getGacId() {
return gacId;
}


public void setGacId(Integer gacId) {
this.gacId = gacId;
}

public String getJsonpCallback() {
return jsonpCallback;
}


public void setJsonpCallback(String jsonpCallback) {
this.jsonpCallback = jsonpCallback;
}


public String getReceiveValidateCode() {
return receiveValidateCode;
}


public void setReceiveValidateCode(String receiveValidateCode) {
this.receiveValidateCode = receiveValidateCode;
}


public CardReceiveRecordBO getCardReceiveRecordBO() {
return cardReceiveRecordBO;
}


public void setCardReceiveRecordBO(CardReceiveRecordBO cardReceiveRecordBO) {
this.cardReceiveRecordBO = cardReceiveRecordBO;
}


}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值