To call the WebService from javascript, you must first add the [ScriptMethod] annotation, for example
[System.Web.Script.Services.ScriptService]
public class MyWebService : System.Web.Services.WebService
{
}
To call a web service, you must enable it in the ScriptManager.
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Script/jquery-1.3.2.js" />
<asp:ScriptReference Path="~/Script/jquery-ui-1.7.2.custom.min.js" />
<asp:ScriptReference Path="~/Script/json.jquery.js" />
</Scripts>
<Services>
<asp:ServiceReference Path="~/WebService.asmx" />
</Services>
</asp:ScriptManager>
Now you need to call webservice as follows
[WebServiceNameSpace].MyWebService.MyWebMethod(
parameters,
function (e)//Function for success
{
},
function (e)//Function for failure
{
});
it will look like for you:
var id=1;
var text="bla bla";
NameSpace.WebService.SetTest(id, text,
function (e){
},
function (e){
});
jQuery webservice. this