js端:
$.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'>报名成功!</font>");
}else{
$("#resultDiv").html("<font color='#eb2700'>报名失败!</font>");
}
},
error:function(e){
$("#resultDiv").html("<font color='#eb2700'>报名失败!</font>");
}
});
服务器端:
[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"}])");
}
}