Passing POST variable to datatable.

Passing POST variable to datatable.

TomAgTomAg Posts: 3Questions: 2Answers: 1
edited April 2016 in Free community support

Hello,

I am trying to pass a POST to a class that return JSON data. I have tried all the methods that I could find in the documentation and the forums. I have noticed the syntax for these datatables has changed greatly version to version and I want to make sure that my syntax is correct. I am using datatables within a web app if that makes any difference. Datatables worked fine with the using GET but the query variable is too large for URL parameters.

Any help is greatly appreciated!

 var otable_backlog = $j("#table_backlog").DataTable({
    "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
                     "processing": true,
                     "serverSide": true,
                     "ajax":
                     {
                     "url": "/polarion/BacklogJSON/getJSON",
                     "type": "POST",
                     "data": query
                     },
                     "columns": [
                        {"data":"projectID"},
                        //{"data":"priority"},
                        {"data":"id"},
                        {"data": "title" },
                        {"data":"status"},
                        {"data":"initialEstimate"},
                        {"data":"storyPoints"},
                        {"data":"assignee"},
                        {"data":"plannedIn"}
                    ]
                    
            });  

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,985Questions: 1Answers: 10,162 Site admin

    The above looks absolutely fine. Does it work as expected? It uses the 1.10 style parameter names (which are fully documented here - the legacy parameters are not documented there at all).

    Allan

  • TomAgTomAg Posts: 3Questions: 2Answers: 1
    Answer ✓

    I had another developer review the code, he fixed it:

    var otable_backlog = $j("#table_backlog").DataTable({
    "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
    "processing": true,
    "serverSide": true,
    "ajax":
    {

                     "url": "/polarion/BacklogJSON/getJSON",
                     "type": "POST",
                     //"query": postQuery,
                     "data": { 
                            "query": query
                     }
                     },
                     "columns": [
                        {"data":"projectID"},
                        //{"data":"priority"},
                        {"data":"id"},
                        {"data": "title" },
                        {"data":"status"},
                        {"data":"initialEstimate"},
                        {"data":"storyPoints"},
                        {"data":"assignee"},
                        {"data":"plannedIn"}
                    ]
    
This discussion has been closed.