button click to update table using ajax/post/php
button click to update table using ajax/post/php
mehti
Posts: 35Questions: 13Answers: 0
Hi guys,
I am trying to implement a function which calls php using ajax post function. I can extract the data and I can clear the table however for some reason I cannot get it to display the new output. here is my code
function getResults() {
var transferTo;
var transferFrom;
var currency;
var amount;
transferTo = document.getElementById("transferTo").innerHTML.replace("<span class=\"caret\"></span>", "");
transferFrom = document.getElementById("transferFrom").innerHTML.replace("<span class=\"caret\"></span>", "");
currency = document.getElementById("currency").innerHTML.replace("<span class=\"caret\"></span>", "");
amount = document.getElementById("amount").value;
var postData = {
"transferTo": transferTo,
"transferFrom": transferFrom,
"currency": currency,
"amount": amount
};
if ($.fn.dataTable.isDataTable('#results')) {
$('#results').DataTable.clear();
$('#results').DataTable.ajax.reload();
}
else {
$('#results').DataTable({
"ajax":
{
url: "php/getMoneyTransferResults.php",
type: "POST",
dataType: "json",
data: postData
}
});
}
}
Any help would be much appreciated.
This discussion has been closed.
Answers
I've managed to solve this. However, if anyone knows more elegant solution please do let me know.