加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax跨域访问jsonp

发布时间:2020-12-16 02:10:21 所属栏目:百科 来源:网络整理
导读: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' , jso

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 + ")");

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读