• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
james1207

博客园    首页    新随笔    联系   管理    订阅  订阅

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;
            }
        }
    }
}


 

 

posted @ 2013-09-02 17:58  Class Xman  阅读(169)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3