zoukankan      html  css  js  c++  java
  • c#中$.ajax的使用

     
    <script type="text/javascript">
     var telphone = { type: "getphone", "num": dianhua, "typestr": index };
                    $.ajax({
                        type: 'POST',
                        url: '/webService/GetMobile.ashx',
                        data: telphone,
                        dataType: 'text',
                        success: (function (data) {
                            if (data == "ok") {
                                alert("提交成功!");
                                $(".storesContents_Box1:eq(" + index + ") .txtmobile").val("");
                                $(".storesContents_Box1:eq(" + index + ") .txtmobile").focus();
                            }
                            else {
                                alert("提交失败!");
                            }
                        })
    </script>
    后台 GetMobile.ashx'
     public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
     
            var type = context.Request.Params["type"];
            var telphoneNumber = context.Request.Params["num"];
            if (!string.IsNullOrEmpty(telphoneNumber))
            {  
                using(EF db = new EF())
                {
                    Telphone xTelphone = new Telphone();
                    xTelphone.Telphone = telphoneNumber;
                    db.Telphone.AddObject(xTelphone);
                    db.SaveChanges();
                }
            }
            switch (type)
            {
                case "getphone":
                    {
                        context.Response.Write("ok");
                        break;
                    }
            }
        }
     
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    
     
    
    
  • 相关阅读:
    mfc中的_T
    zmq的send
    c++内存相关函数
    如何运行linux shell程序
    Dockfile中的命令如何在.sh中执行
    Linux 错误: $' ': command not found
    实战ZeroMQ的PUSH/PULL推拉模式
    Servlet笔记
    进程控制块(PCB)
    Makefile规则介绍
  • 原文地址:https://www.cnblogs.com/ft-Pavilion/p/4481902.html
Copyright © 2011-2022 走看看