Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

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

$
0
0

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">$(document).ready(
            function ()
            {$.ajax(
                {
                    type: "POST",
                    url: "AjaxCallWebMethod(string).aspx/ReturnString",
                    data: "firstName=Swan&lastName=W",
                    //contentType: "application/json; charset=utf-8",
                    dataType: "text",
                    success: function (data)
                    {$("#Text1").html(data);
                    }
                })
            }
            );</script></head><body><form id="form1" runat="server"><div><input id="Text1" type="text" /><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></div></form>
[WebMethod]
        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.

Swan


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>