Donate

WebService Is Undefined Error In ASP.NET 4.0

1. First step is to add reference to the web service using Ajax Script Manager:
<asp:ScriptManager ID="ajaxManager" runat="server">  
     <Services>  
       <asp:ServiceReference Path="~/Services/ProductService.asmx" />  
     </Services>  
   </asp:ScriptManager> 
2. Secondly is to include the namespace in calling the webservice method
From
ProductService.GetProducts(  
            function (data) {  
              $.each(data, function (index, elem) {  
                $("<option />")  
                 .text(elem.ProductName)  
                 .val(elem.ProductID)  
                 .appendTo("#products");  
              });  
            }  
       );  
To
AccessingServerSideDataUsingClientScript.Services.ProductService.GetProducts(  
            function (data) {  
              $.each(data, function (index, elem) {  
                $("<option />")  
                 .text(elem.ProductName)  
                 .val(elem.ProductID)  
                 .appendTo("#products");  
              });  
            }  
       );  

Reference: http://omensblog.blogspot.com/2007/07/aspnet-ajax-web-service-calls-from.html
Greg

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.