how to use ajax.url(''url").load() for post params

how to use ajax.url(''url").load() for post params

DD Posts: 9Questions: 1Answers: 0

I am trying to use ajax.url('myurl').load() with post params.Since 'myurl' is a string I works well for get request.How can I apply the same to post?

Here is my datatable:
$('#example').dataTable( {
"ajax": { "url": "url", "type": "POST", "data":data } } ); } );

Everytime I reload the table ,i need to pass new data to the backend.

How can I achieve it by using ajax.url('myurl').load()?

Could anyone please point me with example.

Answers

  • DD Posts: 9Questions: 1Answers: 0

    I am using my datatable like below:

    $('#example').dataTable( {
    "ajax": {
    "url": "data.json",
    "contentType": "application/json",
    "data": function ( d ) {
    return JSON.stringify( d );
    }
    }
    } );

    I am in need to reload the table.I tried using ajax.url('myurl').load() where I have to pass new JSON data everytime.Is this possible to do?

  • DeTropDeTrop Posts: 8Questions: 1Answers: 1
  • DD Posts: 9Questions: 1Answers: 0

    Hi ThankYou!
    The suggested example gives me the option -"Function which is executed when the data as been reloaded and the table fully redrawn."

    I am trying to pass the json data to server and on every reload json will be different.

    Is this possible?Can anyone help please?

  • DeTropDeTrop Posts: 8Questions: 1Answers: 1

    write a method to get your data to post

    data: getMyFormValuesJSONstringified,...

    ..and onSubmit tableInstance.ajax.reload(); should do the job as long as you don´t need different url...

This discussion has been closed.