Correct these mistakes
1) To Enable the WebService method to be called from Ajax, add the
ScriptService
attribute as
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
2)
The Parameter names are not matching in the Ajax data and in the CS Method, the names should be same, else the data wont get mapped properly
[WebMethod]
public string Registering(string Firstname, string Lastname, string Email, string Password )
{
return "{\"registerPachage\":{\"Id\":26}}";
}
3) Since you are using ASP.Net, if the asmx file in the same project then its not necessry to specify the entire url including the port number in Ajax url, if so then you will have to change it each and every time when the port number gets changed. instead you shall write only the service name and the MethodName as
url: "WebService1.asmx/Registering",
if you using only plain html page then you can write the full url including the port number.
Note: Dont use the name
WebService
, since it is already used in asp.net framework and also the web service name is inherited from it, so give some meaningful name to it.