I previously was just submitting the page to itself to load everything and it worked fine, I just don't want to have to use all the page refreshes so I changed most of my content over to AJAX. I have played around with various things for hours and I am not sure what to do at this point.
I have two select boxes. After both have been chosen I use an AJAX request (call to a PHP function) to populate my DataTable. The table will always be populated with at least one row (usually multiple rows) after the call. I am echo'ing html to make the table rows instead of using rows.add(). The reason for this is frankly I am not sure how to go about passing the data for the rows back (because I need to pass multiple rows after they are queried from a DB) from the PHP function to the javascript where I can use rows.add(). The table fills perfectly fine.
The first problem is the rows don't format with the header (they don't align with the header).
The second problem is after filling it in this way I lose my single select functionality (which was working when I submitted the page to itself to load the table). I am assuming this is because I am filling the table AFTER it has been initialized without using rows.add().
Any input would be appreciated.
This is where I call to the php file and put the data in the table body by id.
function requestData(url, cfunc) {
if (typeof url == 'undefined' | typeof cfunc == 'undefined')
{
return;
}
else{
var xhttp;
xhttp=new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
cfunc(xhttp);
}
};
xhttp.open("GET", url, true);
xhttp.send();
}
}
function getSerialNumberTableBody(xhttp) {
document.getElementById("serialNumberTableBody").innerHTML = xhttp.responseText;
}