AJAX Post request

AJAX Post request

123adsens123adsens Posts: 4Questions: 1Answers: 0

When sending data in POST request , as per most of the solutions , i used below code to send data and its passing correctly in request body. But the issue is the pagination parameteres like start and limit is not passing with this. ANy solution for this ?

data: function ( json ) {
return JSON.stringify( json );
}

Answers

  • kthorngrenkthorngren Posts: 20,329Questions: 26Answers: 4,774

    That small code snippet doesn't give enough information to help. Are you using ajax with ajax.data or jQuery Ajax?

    What does JSON contain and where are the start and limit parameters being generated? Or are you referring to the parameters send by Server Side Processing?

    In order for us to understand what you have to offer suggestions please post a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • 123adsens123adsens Posts: 4Questions: 1Answers: 0
    edited April 2020

    i am using AJax Option with AJAX data and uses

    data: function ( json ) {
    return JSON.stringify( json );
    }

    to pass data on request body
    this passed JSON contains an Object which need to be passed to server.

    Used .on('preXhr.dt', function ( e, settings, data ) to pass start and limit.. This is working on GET requests.

  • 123adsens123adsens Posts: 4Questions: 1Answers: 0

    Here is the jsfiddle..

    https://jsfiddle.net/Lkcnqyus/1/

    if i remove JSON,stringify the parameteres added on preXhr will work correctly.but request body will not be formatted correctly.

  • kthorngrenkthorngren Posts: 20,329Questions: 26Answers: 4,774

    Would something like this work?
    https://jsfiddle.net/fke3byd9/

    You are overwriting, not merging, the original data with return JSON.stringify( fullData );.

    Kevin

This discussion has been closed.