0

This is my web services.

public void VIP_list()
    {
        List<Class_VIPlist> VIPNAME=new List<Class_VIPlist>();
        using (SqlConnection sqlConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString))
        {
            string stR = @"dbo.ListOfVIP";
            using (SqlCommand cmD = new SqlCommand(stR, sqlConn))
            {
               cmD.CommandType = CommandType.StoredProcedure;
                sqlConn.Open();
                SqlDataReader dR = cmD.ExecuteReader();
                while (dR.Read())
                {
                    Class_VIPlist VIPlist=new Class_VIPlist();
                    VIPlist.Patient_Number= Convert.ToInt32(dR[0]);
                    VIPlist.Patient_Name = dR[1].ToString();
                    VIPlist.Amount_Availed = Convert.ToDouble(dR[2]);
                    VIPNAME.Add(VIPlist);
                }
            }

        }

        JavaScriptSerializer js = new JavaScriptSerializer();
        Context.Response.Write(js.Serialize(VIPNAME));
    }

and my ASPX page code is

    <script src="jquery-1.11.3.js" type="text/javascript"></script>
    <script src="jquery.dataTables.min.js" type="text/javascript"></script>
    <link href="jquery.dataTables.min.css" rel="stylesheet" type="text/css" />


   <script type="text/javascript">

     $(document).ready(function () {
        $.ajax({
            url: 'WS_VIPlist.asmx/VIP_list',
            method: 'post',
            dataType: 'json',
            success: function (data) {
                $('#TheVIP').dataTable({
                    data: data,
                    'scrollY': 380,
                    'aLengthMenu': [[10, 25, 50, 100, 200, -1], [10, 25, 50, 100, 200, "All"]],
                    'order': [[1, "asc"]],
                    columns: [
                        { 'data': 'Patient_Number',
                            'searchable': false
                        },
                        { 'data': 'Patient_Name' },

                        { 'data': 'Amount_Availed',
                            'searchable': false,
                                                      'render': function (Availed) {
                                                       var parts = Availed.toString().split(".");
                                                        parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
                                                            return parts.join(".");
                                                        }

                        },

                    ]



                });
            }

        });
    });
</script>

I have no problem when i run this on my localhost its working, it shows record into jquery datatable. But when i published it and browse, no records is displaying on jquery datatable. Can anyone help me to solve my problem?

odlan yer
  • 721
  • 1
  • 7
  • 15

1 Answers1

0

Have you hosted WS_VIPlist.asmx separately on server. In that case you may want to check the service path in your JS code.

What is the output when you hit the service using browser, do you get valid list in response?

Check if the production database table has data that you are expecting!

Solved: Request format is unrecognized for URL unexpectedly ending in

Community
  • 1
  • 1
Nikhil Vartak
  • 5,002
  • 3
  • 26
  • 32
  • Yes, I get valid list when i invoke my web services. – odlan yer Sep 08 '15 at 05:33
  • Then to troubleshoot further I suggest using developer tools in browser and see if web console or network monitor shows any useful info. Just observe it when you make this ajax request to service. – Nikhil Vartak Sep 08 '15 at 06:32
  • [InvalidOperationException]: Request format is unrecognized for URL unexpectedly ending in '/VIP_list'. This is the error i open it in developer tools. – odlan yer Sep 08 '15 at 06:39