Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In asp.net I have a webservice (.asmx) and I call it by ajax post method
JavaScript
$.ajax({
       type: "POST",
       url: "/MyReportService.asmx/ReportData",
       data: "{'objPrintData':'" + jsonDataSet + "'}",
       contentType: "application/json; charset=utf-8",
       dataType: "json",
       success: function (response) {
       },
       failure: function (msg) {
           $('#output').text(msg);
       }
       });

When I host this application how does it work.i.e I can't access this web service.
Thanks
Posted
Updated 16-May-12 19:03pm
v2

try:

XML
<script src="Scripts/jquery-1.4.3.min.js" type="text/javascript"></script>
<script type="text/javascript">

        $(document).ready(function(){
            $("#Button1").click(function() {

                $.ajax({
                    type: "POST",
                    url: "/ASPNET_WebServices_JQuery/DateWebService.asmx/GetDateTime",
                    data: "{}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg)
                    {
                        $("#output").text(msg.d);
                    }
                });

            });
        });



In the above
url: A string containing the URL to which the request is sent.I put the website project name followed by the service file name with extension and then the web method name.

for more refer:
http://www.ezzylearning.com/tutorial.aspx?tid=5872924[^]

http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx[^]
 
Share this answer
 
You might try removing the "/" at the beginning of the url:

url: "MyReportService.asmx/ReportData",

instead of:

url: "/MyReportService.asmx/ReportData",
 
Share this answer
 

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

  Print Answers RSS


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