Datatables works in my local machine but when I publish I have errors

Datatables works in my local machine but when I publish I have errors

henpathenpat Posts: 4Questions: 2Answers: 0

Hi all
I'm working in my localhost, (Windows 2008 R2, Visual Studio 2013, c#), I've created a .aspx page with Datatables and all works perfect!.
After publishing in IIS 7, when I try to reach the page from another computer , I had the error:

Datatables warning: table id =datatable - Ajax error. For more information about this error, please see http://datatables.net/tn/7

When I open the Developer Tools (in Chrome) I saw the error:

Failed to load resource: the server responded with a status of 500 (Internal Server Error) (... link to my ajax url)

I've tried to debug my problem but I have no clue about the error, may be someone can help me?

This is my code:

    <script type="text/javascript">
        $(document).ready(function () {
            var table = $('#datatable').DataTable({
                bServerSide: true,
                sServerMethod: 'post',
                sAjaxSource: 'CustomerService.asmx/GetCustomers2',
                columns: [
                    { data: 'cust_contract_name' },
                    { data: 'cust_id' },
                    { data: 'cust_name' },
                ],
            });
        });
    </script>

And here the link of debug datatables: http://debug.datatables.net/agonon
Thanks in advanced

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    You'd need to look at the server's error logs. A 500 error just means something went wrong at the server-side - it could be anything!

    Allan

  • henpathenpat Posts: 4Questions: 2Answers: 0

    Thanks Allan, I found the solution by adding this in my Web.config file:

      <system.web>
        <compilation debug="false" targetFramework="4.0"/>
        <httpRuntime targetFramework="4.5"/>
        <webServices>
          <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
          </protocols>
        </webServices>
      </system.web>
    

    Problem with the protocol beacuase is disabled by default.

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Excellent - thanks for posting back with the solution! Interesting that POST was disabled by default! I'll keep that in mind should anyone else ask about this.

    Regards,
    Allan

  • shomimshomim Posts: 3Questions: 1Answers: 0

    Hi, all masters,
    I've problem for the DataTable, when I put them running in my local, its run perfectly. But when I publish and access a database, it appear such error for Datatables warning: table id =datatable - Ajax error. For more information about this error, please see http://datatables.net/tn/7

    Look for the console, bring this error : POST http://localhost/Draft/getDraft 404 (Not Found)

    I've insert :
    <protocols>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
    </protocols>
    in the web.config, nothing changed :(

    Any idea?

    Thanks,
    Regards

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    It sounds like either your routing is not correct or the controller name is not correct or something else. Either way, the Ajax request is 404 so you need to either change the URL that the data is being requested from or update the server to accept a request for that URL.

    Allan

  • mikeswebmikesweb Posts: 5Questions: 1Answers: 0

    shomim,
    did you have any luck with this? I am in the same boat.
    thanks,
    Mike

  • mikeswebmikesweb Posts: 5Questions: 1Answers: 0

    BTW,
    if anyone is wondering:
    DataTables debug bookmarklet
    Upload complete - debug code: owozed (view)
    Please include this debug code in support requests

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    It appears to show that /api/salary/al is 404 not found on your server. Can you access that URL directly using your browser?

    Allan

This discussion has been closed.