There are few questions with this name but I want a simple example without lots of details.
There is a button on page, when I click, it must go to server and run a php file on the server. Below code is not working...
my html code (with js) is:
<button onclick="myFunction()">Do it</button>
<script type="text/javascript">
function myFunction(){
var x = new XMLHttpRequest();
x.open("GET","C:\testSample\sample.php",true);
x.send();
return false;
</script>
my php file is:
<?php
echo "Hello world";
?>
Is it about the path of php file that I defined in js ?
sample.php, and not a filepath.sample.phpis on that server then you'd use its HTTP address to access it.