So first of all let me explain how my php/js setup looks like:
So now when you have an idea of how it looks, I have a question about how to do my load, to reload my table without reloading my page.
I know how to do it the simple way like this:
PHP (getTable.php) - this can be any server side code (asp, html, etc..)
<?php
echo '<table><tr><td>TEST</td></tr></table>';
?>
Then, in your JS, you can easily refresh the table by using the load() method:
HTML
<div id="tableHolder"></div>
JS
<script type="text/javascript">
$(document).ready(function(){
refreshTable();
});
/*Call this when table should be updated*/
function refreshTable(){
$('#tableHolder').load('getTable.php');
}
</script>
But how can I use the $('#tableHolder').load('getTable.php'); and transfer the variables needed to getTable.php string/arrays?. Because I need to run a loop in this file running sql queries, instead of in my dashboard.php/functions.php file. Because then I could just update my tables after something has been changed with load.
what I need to do:
//Create all the divs needed (the ones to be updated)
foreach($arrayThings as $projects){
echo'<div id="'.$projects.'"></div>';
}
//JS script that should be triggered when divs has to be updated
/*Call this when table should be updated
* But how can I transfer data to this php file and load it? cant create the table without doing
* some calculations and sql calls to create these tables.
*/
function refreshTable(id){
$('#'+id).load('getTable.php');
}
You can use second parameter in load() to send array. That should send as POST.
$('#'+id).load('getTable.php', { "param1" : "value1" });