I'm attempting to use jQuery to access a method in an asmx webservice. When I try to execute the below jquery call, I get an error 'MyNameSpace' is undefined.
jquery call to webservice:
MyNameSpace.MyWebService.MyMethod(parameter, function (e) { alert('Success') }, function (e) { alert('Failure') });
scriptmanager:
<asp:ScriptManager id="ScriptManager1" runat="server" >
<Services>
<asp:ServiceReference path="MyWebService.asmx" />
</Services>
</asp:ScriptManager>
MyWebService.asmx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Security;
using System.Web.Script.Services;
namespace MyNameSpace{
[ScriptService]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 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 MyWebService : System.Web.Services.WebService
{
[WebMethod]
public void MyMethod(string parameter)
{
//do some cool stuff
}
}
}