jQuery UI Widgets › Forums › DataTable › send dataTable as json via ajax
This topic contains 4 replies, has 2 voices, and was last updated by Dimitar 10 years ago.
-
Author
-
we know how to export dataTable data as json, but how to send it via ajax?
An more importantly how to send dataTable data as json via ajax with some additional information.
What i mean: i have inv.number, inv.data and in the dataTable rows with products.I want to mix into one json inv.number, inv.data and all dataTable data and send it via ajax.var rowData={ Inv: 1, Operator: 2 } var data = "insert=true&" + $.param(rowData); $.ajax({ dataType: 'json', url: 'json_documents.php', cache: false, data: data ....
Hello cpuin,
Here is one possible solution:
var dataTableData = $('#jqxDataTable').jqxDataTable('getRows'); $.ajax({ dataType: 'json', url: 'json_documents.php', cache: false, data: { insert: true, Inv: 1, Operator: 2, records: dataTableData }, ...
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Dear Dimitar,
On thi sway the method to send is GET right?
I ‘m getting this error SyntaxError: JSON Parse error: Unexpected EOF
When use this:
var rowData = { //credit note OperType: 27, Acct: 5, GoodID: 2, records: dataTableData }; var data = "creditnote=true&insert=true&" + $.param(rowData); console.log(data); $.ajax({ dataType: 'json', url: 'json_operations.php?', cache: false, data: data, success: function (data, status, xhr) { .....
Hi cpuin,
Yes, you can use the GET method, too.
As for sending the data, please try adding all your parameters in a single object and pass it as the Ajax call’s data, e.g.:
var rowData = { creditnote: true, insert: true, OperType: 27, Acct: 5, GoodID: 2, records: dataTableData }; $.ajax({ dataType: 'json', url: 'json_operations.php?', cache: false, data: rowData, success: function(data, status, xhr) {.....
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.