码迷,mamicode.com
首页 > Web开发 > 详细

ajax跨域访问jsonp

时间:2014-12-23 17:28:36      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

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

}


ajax跨域访问jsonp

标签:

原文地址:http://blog.csdn.net/shandalue/article/details/42104169

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!