2

In Jquery Datatables editor, is there any option by which data with request sent to the server can be wrapped into JSON? Everywhere, the data is being sent as URL Parameters. And there seems to be no option for JSON request.

Thanks.

5
  • And there seems to be no option for JSON request....how do you know? Can you post in what terms you mentioned this. Commented Jul 10, 2014 at 6:15
  • In all examples given in the website, I searched and found nowhere such an option. Also, I used firebug for those examples, and everywhere the request is being sent in URL parameters format. Thanks Commented Jul 10, 2014 at 6:18
  • do you know about type POST what is the use of it? Commented Jul 10, 2014 at 6:20
  • Yes Sir, Post is a method in which query strings (name/value pairs) are sent in the HTTP message body of request Commented Jul 10, 2014 at 6:28
  • check this out if it helps in understanding what is going on: editor.datatables.net/examples/advanced/localstorage.html Commented Jul 10, 2014 at 6:34

1 Answer 1

4

try this function in ajax section, works for me.

var editor = new $.fn.dataTable.Editor( {
  ajax: {
    url: '...',
    data: function ( d ) {
      return JSON.stringify( d );
    }
  },
  ...
} );
Sign up to request clarification or add additional context in comments.

1 Comment

Welcome to StackOverflow. Code-only answers are discouraged. Please add some details describing why and how this code works to solve the original question. By elaborating and providing these useful details, it is more likely to help the original poster understand why instead of just providing the code that may be a solution. This also helps future visitors to the question understand why it works the way it does. Please read How to Answer in the help section. Thanks for contributing!

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.