zoukankan      html  css  js  c++  java
  • Ajax异步调用使用

    //验证通知号重复
    function checkinformcodeagage() {
    var informcode = $("#txtinformcode").val();
    if (informcode == "") {
    $("#einformcode").attr("style", "display:inline; color:Red;");
    }
    else {
    $.ajax({
    type: "POST",
    url: "ReceiveMessage.aspx?t=checkcode&id=" + encodeURIComponent(informcode),
    success: function (data) {
    if (data == "True") {
    $("#erinformcodeagain").attr("style", "display:inline; color:Red;");
    $("#hidinformcode").val("1");
    }
    else {
    $("#erinformcodeagain").attr("style", "display:none; color:Red;");
    $("#hidinformcode").val("0");
    }
    }
    });
    }
    }


    上面是实现异步调用(Ajax)的函数方法
    有了方法下面需要接受文件去实现,接受文件可以使用“一般处理程序”文件接受,但我更推荐用常用的aspx窗体页面,把窗体上page标签以下的都删除,然后在后台写相应的处理程序就可以了。
    与上面函数对应的:
    protected void Page_Load(object sender, EventArgs e)
    {
    try
    {
    object selecttype = Request.QueryString["t"];
    if (selecttype != null && selecttype.ToString() != string.Empty)
    {
    switch (selecttype.ToString())
    {
    case "informtrain": //通知加改列车
    object id = Request.QueryString["id"];
    if (id != null)
    {
    string context = GetTrainList(int.Parse(id.ToString()));
    Response.Write(context);
    }
    break;
    case "checkcode"://通知号重复
    string informcode = Request.QueryString["id"].Replace('((','(').Replace('),')');
    if (informcode != "")
    {
    string context = GetCodeIsAgain(informcode);
    Response.Write(context);
    }
    break;
    }
    }
    }
    catch (Exception ex)
    {}
    }
    //验证技术通知编号是否在数据库中已存在
    private string GetCodeIsAgain(string code)
    {
    try
    {
    return db.Inform_Bill.Any(i => i.informcode == code).ToString();//返回的是True或False
    }
    catch (Exception ex)
    {
    throw;
    }


    }

  • 相关阅读:
    我的QT5学习之路(二)——第一个程序
    我的QT5学习之路(目录)
    我的QT5学习之路(一)——浅谈QT的安装和配置
    memcpy、memmove、memset、memchr、memcmp、strstr详解
    UDP 单播、广播和多播
    C++重载操作符operator
    testNG官方文档翻译-4 运行TestNG
    testNG官方文档翻译-3 testng.xml
    testNG官方文档翻译-2 注解
    testNG官方文档翻译-1 简介
  • 原文地址:https://www.cnblogs.com/dachuang/p/3654632.html
Copyright © 2011-2022 走看看