Click here to Skip to main content
15,878,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
i have an asp.net application. I have added remote web services as web service reference in my asp.net.I am trying to call that that services but getting internal server error

JavaScript
function Getalldistricts() {
       $.ajax({
           type: "POST",
           url: "/AgriService/Agriculture.asmx/Getalldistricts",
           data: "{}",
           contentType: "application/json; charset=utf-8",
           dataType: "json",
           success: function (data) {

               var obj = JSON.parse(data.d);
               $("#ddlDistrict").empty();
               $("#ddlDistrict").append('<option value="--Select District--">--Select District--</option>');
               for (var i = 0; i < obj.length ; i++) {
                   $("#ddlDistrict").append(' <option value="' + obj[i].districtna + '">' + obj[i].districtna + '</option>');
               }
           },
           //error: function () {
           //    alert("Ajax Error");
           //}
       });
   }


can any one tell me how to call web service which is added as reference in asp.net

What I have tried:

I have tried by changing url path
Posted
Updated 5-May-16 23:07pm

1 solution

 
Share this answer
 
Comments
Veena Hosur 6-May-16 5:14am    
no i have added that asmx as service reference.from that service reference how to call methods
F-ES Sitecore 6-May-16 6:01am    
What do you mean by that? Do you mean your site references another site? Either have your code access that site's service directly, or implement a service on your own site that calls the other service and your code will call the service on your site.
Veena Hosur 6-May-16 6:24am    
i have asmx file in somthing like xyz.abd.133.131/agriportal/agriculture.asmx url.i have added this url as service reference in my asp.net application
F-ES Sitecore 6-May-16 6:39am    
That just creates proxy objects etc so your code-behind can call the web service more easily, it has no relevance to the javascript on any pages you create. As I said, either make your pages call the service directly, or create your own webservice that your js calls, and that webservice calls the remote service.
Veena Hosur 6-May-16 6:55am    
i know code behind can call easily by creating object same thing i mean through ajax i wanted call services how can tell me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900