You must Sign In to post a response.
  • Category: Webservices

    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


    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.
    <asp:Button ID="BtnSheet" runat="server" CssClass="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" Text="Upload" OnClientClick="doValidate();"
    OnClick="BtnSheet_Click" />

    function doValidate() {
    var path = document.getElementById('fulSelect').value;
    if (path == '') {
    alert("Select Excel Sheet");
    return false;
    else {
    function LoadData(path) {
    type: "POST",
    url: "../WebService.asmx/BulkRegistration",
    contentType: "application/json; charset=utf-8",
    data: "{ fulupload: '" + path + "'}",
    datatype: "json",
    success: AjaxloadtblOutSourceSucceeded,
    failure: function() {

    function AjaxloadtblOutSourceSucceeded() {

    #region Bulk Registration
    [WebMethod(EnableSession = true)]
    public DataTable BulkRegistration(string fulupload)

    kindly suggest.
  • #763459
    you can simple write a javascript and call web services directly from it, see below snippet
    <script language="javascript" >
    function onClick(){
    OnTimeOut, OnError);
    return true;
    function OnComplete(args) {
    document.getElementById('Label1').innerHTML = args;
    function OnTimeOut(args) {
    alert("Service call timed out.");

    function OnError(args) {
    alert("Error calling service method.");

    //in aspx define a script manager to call web service
    <asp:ScriptManager ID="ScriptManager1" runat="server" >
    <asp:ServiceReference Path="MyService.asmx" />

    for more detail see below links

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #763470
    1. Can you check the whether URL correct?
    2. Can you try to change it into static method as follows.

    public static DataTable BulkRegistration(string fulupload)

    By Nathan
    Direction is important than speed

  • Sign In to post your comments