How to get values out of Ajax Request from Datatables(JQuery)
How to get values out of Ajax Request from Datatables(JQuery)

I have a Datatable that has the option to edit/remove a row.
When i have edited a row, the modal from Datatables sends a request to my servlet(java) which looks like this:
action: edit
data[34][office]: qsdfqsd
data[34][username]: wqsdfqsdf
data[34][password]: QRSHy7
Now I want to get the values of this request which are:
id=34
office="qsdfqsd"
username="wqsdfqsdf"
password="wqsdfqsdf"
So I can put these values in the databank using java(Servlet).
Is there anyone who can help?
Kind Regards
Answers
Well I don't know any Java so I can't tell you how to get those values into Java. But in Java Script it is fairly easy.
You could use the 'postSubmit' event to get hold of those values like this:
Something similar should work in Java too. It is just object notation.
You can modify the data that is being submitted to the server using the
ajax.data
option as a function. There are examples on that page which show how you can effectively flatten the object.Note that if you do flatten it like that, you loose the ability to do multi-row editing.
Allan
Ye, so I looked into ajax.data and I'm going for the "Add data to the request by manipulating the data object" method but now I still can't find a way to access the in-form input id's to send it with the request.
I gave my fields an ID and now I tried to do this:
editor = new $.fn.dataTable.Editor( {
"ajax": {
url: "GetNotaryServlet",
dataSrc: 'data',
data: function ( d ) {
d.office = $('#office').val();
}
},
"table": "#notaryTable",
"idSrc": 'id',
"fields": [ {
label: "Kantoor:",
name: "office",
id: "office"
}, {
label: "Username:",
name: "username"
}, {
label: "Password:",
name: "password"
}
]
} );
Unfortunately, it gives me an empty value "office = "
Is there something I'm doing wrong?
Allan