zoukankan      html  css  js  c++  java
  • asp.net jquery+ajax异步刷新1

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script charset="gb1232" src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
        <script type="text/javascript">
    //        function sys() {
    //            $.post("test1.ashx", {"Name":$("#text1").val()}, function (data) {
    //                $("#text2").val(data);
    //            });//第一种方案,要在text1添加onblur="sys()"事件响应
            //                }
            $(document).ready(function () {
                $("#text1").blur(function () {
                    $.post("test1.ashx", { "Name": $("#text1").val() }, function jy(data) {
                    $("#text2").val(data);
                  }); 
                });
            });//第二钟方案
        </script>
    </head>
    <body>
        <input type="text" id="text1" />
        转换
        <input type="text" id="text2" />
    </body>
    </html>

    asph处理程序如下:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    namespace 异步刷新
    {
        /// <summary>
        /// test1 的摘要说明
        /// </summary>
        public class test1 : IHttpHandler
        {

            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
                string name = context.Request["Name"];
                context.Response.Write(name);
            }

            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }


     

  • 相关阅读:
    实验axios用户登录及token验证
    vue的路由跳转了,可是页面没有变化
    搞清楚cookie,session,token,JWT
    APP应用测试流程
    Scrum敏捷开发
    APP项目环境及发布平台
    ssh -T git@github.com ssh: connect to host github.com port 22: Connection timed out
    pytest与unitest区别
    数据库三大范式--大白话
    docker 安装mysql挂载/var/lib/mysql目录时启动就退出
  • 原文地址:https://www.cnblogs.com/james1207/p/3297013.html
Copyright © 2011-2022 走看看