六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 43|回复: 0

ajax-20110502

[复制链接]

升级  60%

6

主题

6

主题

6

主题

童生

Rank: 1

积分
30
 楼主| 发表于 2013-1-29 09:16:42 | 显示全部楼层 |阅读模式
 <script src="jquery-1.4.2.js" type="text/javascript"></script>
    <script src="jquery.popup.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#Text1").blur(function () {
                var name = $("#Text1").val();
                name = encodeURI(name)
                $.post("product.ashx?name=" + name, function (data, status) {
                    if (status == "success") {
                        $("#Text2").val(data);
                    }
                });
            });
        });
    </script>
</head>
<body>
    <input id="Text1" type="text" /><input id="Text2" type="text" />
</body>
-------------------------------------------------------------------------------
            context.Response.ContentType = "text/plain";
            string name = context.Request.QueryString["name"];
    
           
            SqlConnection conn = new SqlConnection("server=.;database=student;uid=sa;pwd=123456");
            conn.Open();
            try
            {
                SqlCommand cmd = new SqlCommand("select * from product where proname='" + name + "'", conn);
                SqlDataReader dr = cmd.ExecuteReader();
                dr.Read();
                context.Response.Write(dr["proprice"].ToString());
            }
            catch (Exception)
            {
                context.Response.Write("没有");
            }
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表