Ajax returned from render call does not get handled by DataTables
Ajax returned from render call does not get handled by DataTables
robertsmith
Posts: 2Questions: 1Answers: 0
When I call an ajax request from a button:
{
"render": function (data, type, full, meta)
{ return '<a class="btn btn-info" href="/ProcessRequest/Maint?id=' + full.id + '">Submit</a>'; }
}
I receive a message on the botton of IE:
"Do you want to open or save ProcessRequest.json from ...?"
Instead I was expecting the data (or the error) to be processed by DataTables. Any help would be appreciated.
This discussion has been closed.
Answers
Are you expecting that cell to be populated with the data?
What exactly are you wanting to happen?
Kevin
kthorngren, that is a very good question! I would like the following to happen:
The cell should not change since it only contains the word "Submit" on it.
I am relatively new to DataTables and hope the above is easy to understand. Thank you.
Looks like you want to send the ID of the row to the server. Are you expecting to get just that row's data or the full table in the response?
Datatables is not in control of this request. This is simply an HTML function you are using. Datatables won't automatically do anything with it. You will need to write some code to handle the click event of the row and perform the actions you would like. While this example is not exactly what you want it should give you an idea:
http://live.datatables.net/qemodapi/1/edit
Within the click event you would use an ajax request to the server and in the success function update the Datatable or use an alert to display an error or other message. There are various Datatable API's you can use to update the Datatable. Depends on what exactly you want to update.
You would use something like
row().data()
to update just the row data. Or you could useajax.reload()
to have Datatables clear and fetch the entire table using the original ajax URL in theajax
option.For more specific help maybe you can outline step by step what you are trying to do.
Kevin