Execute a PHP command in JavaScript

Hello, I have a issue executing PHP commands. I am often using HTML and JavaScript for building blank applications. Sometimes I need to execute PHP commands, like
sc_redir() for this example. Is there a solution to execute these php commands in Javascript?
I tried to make an AJAX request to an php file which I created in the internal library section but it doesn’t seem to work.
Here’s my code:

sc_include(grid.php);
?>
button.innerHTML = "Ablauf";
				var userdata = {
						'sql4':'21-G-2010'
					}
				button.onclick = function(){
					$.ajax({
						type: "POST",
						url: "../grid_dbo_AL_QS/grid_dbo_AL_QS.php",
						data:userdata, 
						success: function(data){
							console.log("SUCCESS!");
						}
					});
        		};
				button.classList.add("scButton_default");
				node.appendChild(button); 
				parent.appendChild(node);
   <?php             

And here is my php file which is located in the internal library section:

0| <?php
1|
2|     if (isset($_POST['sql4'])) {
3|     //$variable = $_POST['sql4'];
4|     sc_redir("al_projektmanagementtool");
5|     }
6| ?>