• mvc Ajax 跨域请求


    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"}])");
    }
    }

  • 相关阅读:
    js基础整理总结
    pyinstaller打包django项目成exe以及遇到的一些问题
    Django对接SQL Server服务
    死锁
    python 之路
    Python注释
    Django2.1迁移数据库出错
    一行 Python 代码实现并行
    【转载】Python 类定义与对象
    关于盒模型布局在UC上的兼容处理
  • 原文地址:https://www.cnblogs.com/Xujg/p/4350322.html
Copyright © 2020-2023  润新知