Call a method from server-side, but I can't get it RRS feed

  • Question

  • User1572049755 posted

    Hi all,

    Thank you for your time. I am learning how to use Ajax to call a server method and return some value. But, my test code can't return a sting. Below is my code.

    <script src="Scripts/jquery-2.1.3.js"></script>
        <script type="text/javascript">
                function ()
                        type: "POST",
                        url: "AjaxCallWebMethod(string).aspx/ReturnString",
                        data: "firstName=Swan&lastName=W",
                        //contentType: "application/json; charset=utf-8",
                        dataType: "text",
                        success: function (data)
        <form id="form1" runat="server">
            <input id="Text1" type="text" />
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            public static string ReturnString(string firstName,string lastName) 
                string Text = "Hello"+firstName+lastName;
                return Text;

    So, kindly provide a solution and provide me a good tutorial about how to use Ajax. Besides call method from server-side, I also want to learn how to call WebAPI, WCF...

    Please help me.


    Sunday, May 3, 2015 11:04 PM


All replies