javascript - Web Service method name is not valid c# json ajax -
i making email contact form ajax post on umbraco site, halway thru , testing ajax part , "web service method name not valid" error when runs.
i have booking.cs in app_code, booking.asmx in webservice folder,
[webservice(namespace = "http://localhost/")] [webservicebinding(conformsto = wsiprofiles.basicprofile1_1)] [system.web.script.services.scriptservice] public class booking : system.web.services.webservice { public string email { get; set; } [webmethod] [system.web.script.services.scriptmethod(responseformat = system.web.script.services.responseformat.json)] public string saveit(string email) { try { return "success"; } catch (exception er) { return "error"; } }
}
javascript:
$("#email_popup_submit").click(function (e) { $.ajax({ url: '/webservice/booking.asmx/saveit', type: 'post', contenttype: 'application/json; charset=utf-8', datatype: 'json', data: { 'email': 'testemail' }, beforesend: function () { }, success: function (data) { //console.log(data.d); if (data.d == "success") { e.preventdefault(); // console.log('success!'); } else { } }, error: function (jqxhr, textstatus, errorthrown) { console.log("error '" + jqxhr.status + "' (textstatus: '" + textstatus + "', errorthrown: '" + errorthrown + "')"); } }); })
uncomment following line service code
enabled
call javascript/ajax
[system.web.script.services.scriptservice]
Comments
Post a Comment