How to call webservice from Ajax
Are you looking for a way to call webservice from Ajax then read this thread to know how to call it
Hi,
I want to call webservice from client-side. I've used below code. I'm not getting any response and I've kept breakpoint also in my webservice it also not hitting.
When I invoke my webservice manually its working.
Code:
<asp:Button ID="BtnSheet" runat="server" CssClass="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" Text="Upload" OnClientClick="doValidate();"
OnClick="BtnSheet_Click" />
Script:
function doValidate() {
var path = document.getElementById('fulSelect').value;
if (path == '') {
alert("Select Excel Sheet");
return false;
}
else {
LoadData(path);
}
}
function LoadData(path) {
$.ajax({
type: "POST",
url: "../WebService.asmx/BulkRegistration",
contentType: "application/json; charset=utf-8",
data: "{ fulupload: '" + path + "'}",
datatype: "json",
success: AjaxloadtblOutSourceSucceeded,
failure: function() {
alert("fail");
}
});
function AjaxloadtblOutSourceSucceeded() {
alert("sucess");
}
}
</script>
WebMethod:
#region Bulk Registration
[WebMethod(EnableSession = true)]
[System.Web.Script.Services.ScriptMethod()]
public DataTable BulkRegistration(string fulupload)
{
}
#endregion
kindly suggest.