[WebService(Namespace = "testService",Name="MyService")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class ServiceCompas : System.Web.Services.WebService {
public ServiceCompas () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld() {
return "Hello World";
}
}
Thanks & Regards
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
venksdawson
Member
4 Points
10 Posts
How does jquery work with webservices?
Nov 29, 2010 04:00 AM|LINK
Hi,
I am very new to jquery. Can anybody please tell me how jquery works with webservices?
Venks Dawson
asteranup
All-Star
30184 Points
4906 Posts
Re: How does jquery work with webservices?
Nov 29, 2010 04:17 AM|LINK
Hi,
Find The code Below-
HTML-
<body> <script type="text/javascript"> $(document).ready(function() { $("#Button1").click(function(event) { event.preventDefault(); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "ServiceCompas.asmx/HelloWorld", data: "{}", dataType: "json", success: function(msg) { alert(msg.d); }, error: function(c, textStatus, errorThrown) { $("#result").html(XMLHttpRequest + "\r\n" + textStatus + "\r\n" + errorThrown); } }); }); }); </script> <div id="result"></div> <input id="Button1" type="button" value="button" /> </body>WebService-[WebService(Namespace = "testService",Name="MyService")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class ServiceCompas : System.Web.Services.WebService { public ServiceCompas () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string HelloWorld() { return "Hello World"; } }Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
raghav_khung...
All-Star
32835 Points
5563 Posts
MVP
Re: How does jquery work with webservices?
Nov 29, 2010 05:15 AM|LINK
Hi Venks,
I have written a complete article on Calling web service using jQuery in ASP.NET
Here is the demo http://www.codeasp.net/assets/demos/articles/calling-web-service-using-jquery/calling-web-service-using-jquery.aspx