无法在ajax中调用webservice

时间:2015-02-17 12:16:10

标签: c# asp.net ajax web-services

我尝试了很多,但我不能解决任何人帮助我

我的剧本

 function insertparentdetais() {
        alert(1);
        var firstname = document.getElementById('ContentPlaceHolder1_firstnametxt').value;
        var lastname = document.getElementById('ContentPlaceHolder1_lastnametxt').value;
        var email = document.getElementById('ContentPlaceHolder1_emailidtxt').value;
        var password = document.getElementById('ContentPlaceHolder1_passwordtxt').value;
       // var securityquestion = document.getElementById().value;
        var answer = document.getElementById('ContentPlaceHolder1_answertxt').value;
        var birthofpalce = document.getElementById('ContentPlaceHolder1_placebirthtxt').value;
       // var motherlabnguage = document.getElementById().value;
        var birthdate = document.getElementById('ContentPlaceHolder1_birthdatetxt').value;

        var parameters = "{'firstname':'"+firstname+"','lastname':'"+lastname+"','email':'"+email+"','password':'"+password+"','answer':'"+answer+"','birthofpalce':'"+birthofpalce+"','birthdate':'"+birthdate+"'}";
      //  alert(parameters);
        $.ajax({
            type: "POST",
            url: "<%= ResolveUrl("~/App_Code/WebService.asmx/Insertparentdetails")%>",
            data: parameters,
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            success: function (msg) {
                alert("Sucessfully Registered!!!");
               return false;
            },
            error: function (msg) {
                alert(2);
                return false;
            }
        })

    }

我的网络服务方法

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public int Insertparentdetails(string firstname, string lastname, string email, string passwors, string answer, string birthofpalce, string birthdate)
{
    return 1;
}

在我的网络配置文件中,我添加了一个Web服务的处理程序

 <remove verb="*" path="*.asmx"/>
  <add verb="*" path="*.asmx" validate="false" 
       type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,  
       PublicKeyToken=31bf3856ad364e35"/>

我尝试了很多,但网络方法并没有打电话不知道我哪里出错了,欢迎你的帮助谢谢

0 个答案:

没有答案