Trying to send the Form Data which is called as dataValues and other values defined in d
Trying to send the Form Data which is called as dataValues and other values defined in d
maniya
Posts: 78Questions: 13Answers: 0
I have situation where i am trying to fetch the data from the cfm file but it is not sending the formvalues to the server so it can process and send me the data back and i can refresh my datatables again
var parentAjaxTable = $('#tblData').DataTable({
ajax: {
url: 'data.cfm',
type: 'POST',
data: function(d) {
d.section = 'rowUpdate';
d.urlstatus = urlstatus; // You'll need to define _status or pass it as a parameter
d.dformat = $('.application').attr('data-format').toUpperCase();
return d;
},
dataSrc: function(json) {
// Modify the data returned from the server to include dataValues
json.dataValues = dataValues;
return json.data;
}
},
columns: [
{ data: "CheckBoxIcon" },
{ data: "Employee" },
{ data: "Type" },
{ data: "weekending" },
{ data: "Submission_Date" },
{ data: "Approved/Rejected By" },
{ data: "Date Approved" },
{ data: "Totalhours" },
{ data: "viewIcon" }
]
});
function reqUpdate(dataValues, type, rowID, _status) {
var table = $('#tblData').DataTable(); // Get the DataTable instance
// Update the data source parameters
table.ajax.url('data.cfm?section=rowUpdate&urlstatus=' + _status).load(function(json) {
// Perform actions after the table has been updated
// For example, you can update the table data using the dataValues
table.clear();
table.rows.add(dataValues);
table.draw();
}, false); // Set the second parameter to false to prevent the table from being redrawn automatically
// Get the current data from the DataTable
var currentData = table.ajax.params().data;
// Merge the current data with the new dataValues
var mergedData = Object.assign({}, currentData, dataValues);
// Send the merged data along with the AJAX request
table.ajax.reload(null, false); // The second parameter is set to false to prevent the table from being redrawn automatically
}
i am trying different techniques but unable to send the dataValues to the server, not sure what is going wrong in here, please guide
Answers
It seams like it should be POSTing
section
,urlstatus
anddformat
values to thedata.cfm
route. If that isn't working, can you link to a page showing the issue please.Allan
i do not have a page, its intranet website but i confirm that only url which is rowUpdate and urlstatus is going to the data.cfm, no post is pushed
Use the browser's network inspector to get the Payload sent. Please paste the payload into the thread so we can see the request sent.
Kevin
This is the Payload which is sent
section=rowUpdate&urlstatus=r&_=1713530632701
i updated a function a little bit to do everything in one call
In lin 40 you are doing this:
Possibly you will want to use
ajax.reload()
instead to take advantage of theajax
config.Kevin