JS End:
$.ajax ({
Type: "Get",
Async:false,
Url:url,
Data: ' bid=0&xingming= ' + uName + ' &phone= ' + Utel + ' &bname= ' + ULP + ' &sex=0&renshu=1 ',
Cache:false,
DataType: "Jsonp",
JSONP: "Callbackparam",
Jsonpcallback: "JsonpCallback1",
Success:function (JSON) {
if (json[0].msg== "OK") {
$ ("#resultDiv"). HTML ("<font color= ' #03bb74 ' > registration successful! </font> ");
}else{
$ ("#resultDiv"). HTML ("<font color= ' #eb2700 ' > registration failed! </font> ");
}
},
Error:function (e) {
$ ("#resultDiv"). HTML ("<font color= ' #eb2700 ' > registration failed! </font> ");
}
});
Server-side:
[HttpGet]
public void Ajaxmake ()
{
String callbackfunname = request["Callbackparam"];
String name = request["Xingming"];
string phone = request["Phone"];
string sex = request["Sex"];
int Renshu = Convert.ToInt32 (request["Renshu"]);
String bname = request["Bname"];
Renshu = Renshu > 20? 20:renshu;
BOOL result = Kftbll.makeman (0, name, phone, sex, bname, Renshu);
if (result)
{
Response.Write (Callbackfunname + "([{\" msg\ ": \" Ok\ "}])");
}
Else
{
Response.Write (Callbackfunname + "([{\" msg\ ": \" Err\ "}])");
}
}
MVC Ajax cross-domain request