0

I have tried to convert the below datatable javascript from GET to POST method. The code looks as below,

var pagination = new DatatablesPagination({
    tableSelector: '.casesTable',
    tableContainer: data.tableContainer,
    onError: callbacks.onError,
    iDisplayLength: recordsPerPage,
    pages: 4,
    sAjaxSource: ajaxSource,
    fnServerParams: function(aoData) {
        $.each(additionalQueryParams, function(index, additionalQueryParam) {
            aoData.push(additionalQueryParam);
        });
    },
    fnDrawCallback: function(settings) {
        if (typeof callbacks !== "undefined" && typeof callbacks.onDrawOfAssociatedCases !== "undefined") {
            callbacks.onDrawOfAssociatedCases(settings, reportHolder);
            if ($("#associatedCasesTableWrapper").is(":visible")) {
                updateLocation();
            }
        }
    }
}):

I have tried adding sServerMethod: POST as below, but there is no luck.

   sServerMethod: 'POST',
        sAjaxSource : ajaxSource,
        fnServerParams : function ( aoData ) {
            $.each(additionalQueryParams, function(index, additionalQueryParam) {
                aoData.push( additionalQueryParam );
            });
        },

Could anyone help me to convert this method from GET to POST please?

2
  • what is the console error your are getting in network? Commented Feb 9, 2018 at 9:34
  • 405 method not allowed in status code Commented Feb 9, 2018 at 14:55

1 Answer 1

0

Might be your Service/Server setup would be configured with GET, but your are trying to access it with POST from ajax. Try changing the service setup to POST.

Please refer,

https://datatables.net/forums/discussion/21287/ajax-load-results-in-networkerror-405-method-not-allowed

POST 405 (Method not allowed) when trying to post AJAX request - Laravel 4

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.