ajax跨域访问jsonp

前端之家收集整理的这篇文章主要介绍了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 + ")");

}

原文链接:https://www.f2er.com/ajax/163962.html

猜你在找的Ajax相关文章