ajax跨域访问jsonp

ajax跨域访问:


1.前台:

try{

$.ajax({

async:false,

cache:false,

data:{"vote_id":vote_id,"shareholder_card":shareholder_card,"stock_type":stock_type,"currency_type":currency_type},

url:sivrs_hasCard_url,

dataType:‘jsonp‘,

jsonp: "callback",

success:function(result) {

var results=eval(result)

var result=results.result;

if(result == 1){

alert("股东卡号已存在");

return false;

}

},

error:function(XHR, textStatus, errorThrown){

                //alert(‘error: ‘ + errorThrown);//not login

            },

timeout:5000

});

} catch(ex) {

alert("erorr");

}






2.后台:

/*

* 查询股东卡号是否存在

*/

@RequestMapping(value="/hasCard.do")

public void hasCard(HttpServletRequest request,

HttpServletResponse response, Model model){

String vote_id =request.getParameter("vote_id");

String shareholder_card =request.getParameter("shareholder_card");

String stock_type =request.getParameter("stock_type");

String currency_type =request.getParameter("currency_type");


String callback = request.getParameter("callback");

String result=jedisService.hasCard(vote_id,shareholder_card,stock_type,currency_type);

jsonAjax(response, callback + "(" + result + ")");

}


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。