0

Have a web application I am building using Visual Studio 2022, .Net (not Core) that has a page that uses ajax to gather data for a DataTables table. Problem I am having is that the ajax endpoint never gets called and no errors are reported. I have several others working fine. When I use the browser developer to step through the code, it just simply skips over the call. I would expect there to be an error somewhere but it simply just doesnt even try to hit the ajax endpoint. It has to be something very simple I am missing so if anyone can help.

(the reason for the variable assignment to 'table' is that the table get recreated over and over based on user input for filtering and we use the variable to destro the current data)

The jQuery code, contained within a function:

         table = $('#feelist').DataTable({
                //'pageLength': tablelength,
                //'lengthMenu': [[10, 15, 20, 25, 50, 1000], [10, 15, 20, 25, 50, 1000]],
                'ajax': {
                    'url': '/LoadFeeScheduleFees/',
                    'type': 'POST',
                    //'dataType': 'json'
                    'data': {
                        'clinicid': clinicid,
                        'standardfeeid': standardfeeid,
                        'feescheduleid': feescheduleid
                    }
                },
                'columns': [
                    { 'data': 'Id', 'name': 'Id' }, // 0
                    { 'data': 'ServiceCode', 'name': 'ServiceCode' }, // 1
                    { 'data': 'ADACode', 'name': 'ADACode' }, // 2
                    { 'data': 'ServiceDescription', 'name': 'ServiceDescription' }, // 3
                    { 'data': 'CurrentStandardFee', 'name': 'CurrentStandardFee' }, // 4
                    { 'data': 'CurrentAllowableFee', 'name': 'CurrentAllowableFee' }, // 5
                    { 'data': 'LastFeeDate', 'name': 'LastFeeDate' }, // 6
                    { 'data': 'NewInsuranceFee', 'name': 'NewInsuranceFee' }, // 7
                    { 'data': 'Fill', 'defaultContent': '' } // 8
                ],
                'columnDefs': [
                    { 'visible': false, 'targets': [0] },
                    { 'sortable': false, 'targets': [8] }
                ],
                'order': [
                    [1, 'asc']
                ]
            });
        }
5
  • "When I use the browser developer to step through the code, it just simply skips over the call." - Can you clarify what you're referring to here? Are you debugging the DataTables 3rd party code itself, or referring to something in your own code? The code shown doesn't make an explicit AJAX call but does appear to configure DataTables to use AJAX when it needs to load data. Does the same DataTables instance work as expected with hard-coded data?
    – David
    Commented Jul 28 at 14:36
  • You are correct, it is using the ajax call functionality of DataTables. If I hard code the table and then call datatables to format, works fine. The issue I am experiencing is that it seems to not even TRY to call the ajx endpoint to retrieve data Commented Jul 28 at 14:41
  • 1
    Are you able to create a minimal reproducible example as a Stack Snippet which demonstrates the problem? Any AJAX call therein would of course fail, but if the error is that it's not attempting to make the call in the first place then that wouldn't affect the test.
    – David
    Commented Jul 28 at 14:44
  • Console messages? Are you actually calling the function containing the code? Does the end point exist and is it called what you called it
    – mplungjan
    Commented Jul 28 at 14:48
  • Feel free to delete this since it is not really useful for anyone but you
    – mplungjan
    Commented Jul 29 at 5:44

1 Answer 1

0

Ok, I am an IDIOT !!!

I went back and traced not only the code within this function, but step by step leading up to it. I found a line of code that removed the reference placeholder for the DOM element before the DataTables ever got called so I was trying to apply the DataTables code to a non existent DOM element!!!

Thanks to all those that replied.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.