I want to get URL parameter with PHP and send the parameter (ID) to a JS function.
This is what I tried.
PHP:
$param = $_GET['param'];
if($param != "" || $param == NULL || (!empty($param))){
echo '<script type="text/javascript">',
'onparam($param);',
'</script>';
}
JS:
function onparam(param) {
$.ajax({url: "AJAX.php", data: 'id=' + param + '&switch_content=details', success: function(result){
$("#data-table").html(result);
}});
document.getElementById("overlay").style.display = "block";
}
I tried to put the parameter in a variable and call the JS function with it. In the next step I tried to catch the variable in the JS function to put it in the string of "data:".