Call ASP.NET web service method from JavaScript

前端 未结 5 751
Happy的楠姐
Happy的楠姐 2020-12-20 04:45

I have the web service:

[WebMethod]
public void SendMail(string _name, string _email, string _message)
{
    //Create Mail Message Object with content that y         


        
5条回答
  •  没有蜡笔的小新
    2020-12-20 05:31

    You need to do something very important: Add the ScriptService attribute the class so that it can be called from a Javascript as in this example:

    [ScriptService]
    public class SimpleWebService : System.Web.Services.WebService 
    {
        // ...
    }
    

    http://msdn.microsoft.com/en-us/library/system.web.script.services.scriptserviceattribute.aspx

提交回复
热议问题