sAjaxSource URL too long

sAjaxSource URL too long

azulahimeazulahime Posts: 6Questions: 3Answers: 1
edited October 2022 in Free community support

Hi, I'm currently working on a Django project which makes use of a server-side data table. Just to give a background on how the tool works, before generating the data table and its contents, users are given the option to select columns which would be included in the data table. So far this is working if the user selects < = 18 columns but if they select more than that, I get the 404-error message. Indicated below is a part of my code for the data table and I saw that by changing the method to post, it should work but I'm not really sure how to apply it in this setup. When I tried changing sAjaxSource to ajax: url... type..., I got a different error message related to iDisplayStart. I was hoping someone could give me any insights on how to resolve this and I was also wondering if it's possible to remove some of the parameters automatically included in the url. Also, here's a link to the package I used for the server-side table just in case it may be related to the problem: https://pypi.org/project/django-serverside-datatable/

       var table = $('#table').DataTable( {
            scrollX: true,
            scrollY: "500px",
            lengthChange: false,
            pageLength:5000, 
            buttons: [ 'excel' ],
            serverSide: true,
            sAjaxSource: "http://IP/sctagging/materialtaggingdata/",  
            columns: columndata,
       })

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    sAjaxSource is old, it would be better to use ajax. That said, all DataTables does is read the data that comes back from the server, so if you're getting a "404" error, that'll be something going wrong on the server you'll need to debug. Best place would be check your server-side log,

    Colin

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Try:

    ajax: {
      url: 'http://IP/sctagging/materialtaggingdata/',
      type: 'post'
    }
    

    And handle the data at the server-side as POST data.

    Allan

  • azulahimeazulahime Posts: 6Questions: 3Answers: 1

    Hi Allan,

    I tried using that option instead of sAjaxSource but I got an error related to iDisplayStart. Would you happen to know why?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    What's the error you received?

    Colin

  • azulahimeazulahime Posts: 6Questions: 3Answers: 1

    Hi Colin,

    Upon checking the console log, this is the error that I got: the server responded with a status of 403 (Forbidden).

    Upon clicking on the link associated with the error message, this is the specific error the debug page highlights:

    MultiValueDictKeyError at /sctagging/materialtaggingdata/
    'iDisplayStart'

    Aly

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    iDisplayStart is a legacy option that would have been triggered by your use of the legacy sAjaxSource parameter. draw is the parameter name now - see the docs here.

    If you really want to use the legacy stuff, you can do so as described here.

    Allan

Sign In or Register to comment.