日期:2014-05-16  浏览次数:20422 次

jquery $.ajax()

  $(function () {
            $("#Button1").click(function () {
                $.ajax({
                    type: "post",
                    url: "JQUERY.aspx/Inserts",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                 data: "id=" + $("#TextBox1").val() + "&name=" + $("#TextBox2").val() ,
             
                    success: function (data) {
                        alert("ok");
                    },
                    error: function (xhr) {
                        alert("错误" + xhr.responseText);
                    }
                });
                $("#Button1").attr("disabled", true);
               // return false;
            });
        }); 
    </script>


    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>   
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
     <asp:button ID="Button1" runat="server" text="Button" onclick="Button1_Click" />