Ajax cross-domain access JSONP

Source: Internet
Author: User

Ajax cross-Domain access:


1. Front Desk:

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 ("the shareholder card number already exists");

Returnfalse;

}

},

Error:function(XHR, Textstatus, Errorthrown) {

//alert (' ERROR: ' + errorthrown);//not Login

},

timeout:5000

});

} catch(ex) {

Alert ("Erorr");

}






2. Backstage:

/*

* Check if there is a shareholder card number

*/

@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 cross-domain access JSONP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.