gdccx 发表于 2013-1-29 09:16:42

ajax-20110502

 <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("没有");
            }
页: [1]
查看完整版本: ajax-20110502