首页 > 代码库 > ajax 简单学习

ajax 简单学习

客户端代码
function
login(type) { $.ajax({ type: "post", url: "logindo.aspx", data: { user: $("#name").val(),//对应<input type="text" id="name"/>的值 pwd:pwd ////对应<input type="password" id="name"/>的值 }, success: function (data) { if (data =http://www.mamicode.com/= 0) { alert("用户名或密码错误"); } else { alert("登陆成功"); } }, error: function (a, b, c) { alert(a + b); } });}</script>
protected void Page_Load(object sender, EventArgs e)        {
       //vs提供的SqlDataSource绑定数据源控件
       //<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:online_work_managementConnectionString %>"
       //ProviderName="<%$ ConnectionStrings:online_work_managementConnectionString.ProviderName %>"
//SelectCommand="select_user" SelectCommandType="StoredProcedure">
            //<SelectParameters>
            //    <asp:Parameter Name="name" Type="String" />
            //    <asp:Parameter Name="pwd" Type="String" />
            //</SelectParameters>
           //</asp:SqlDataSource>

       //对应的存储过程为:
       //CREATE DEFINER=`root`@`localhost` PROCEDURE `select_user`(in user varchar(20), in pwd varchar(20), in user_type int(1))
       //begin
       // select * from user where username = name and password = pwd;
       //END SqlDataSource1.SelectParameters[
0].DefaultValue = http://www.mamicode.com/Request.Form["name"]; SqlDataSource1.SelectParameters[1].DefaultValue = http://www.mamicode.com/Request.Form["pwd"]; DataView dv = SqlDataSource1.Select(DataSourceSelectArguments.Empty) as DataView; Response.Write(dv.Table.Rows.Count); Response.End(); }