hi
can any one tell me how to call webservice through json query here is my code.
i want pass two variable and i want to get the result of that methos say Add methos of following service.
for webservice
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://localhost:54727/WebSite1/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {
public WebService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public int Add(int x, int y)
{
return x + y;
}
and my code for script is as follows
<script type="text/javascript">
function getread() {
$.ajax({
type: "Post",
url: "http://localhost:54727/WebSite1/WebService.asmx/HelloWorld",
data: "{}",
contentType: "json",
success: funcation(msg)
aler(msg);
});
}
</script>
which is not working and i'm call this service through
button
<asp:TextBox ID="text1" runat="server" ></asp:TextBox>
<asp:TextBox ID="text2" runat="server" ></asp:TextBox>
<span id="text" runat="server"></span>
<input id="in" type="button" onclick="getRead" value="Check" />
please tell me where is my misstack in the code.