title: Trying to run a local PHP file from a Javascript, Both locally
body: <p>I have a Javascript that calls a PHP script using AJAX get method. If i run the PHP script externally it works fine and creates the file connections.txt. But with JS it is not working </p>
  
  <pre><code>$(document).on("click", "#target2", function(){
  var arr = ["one","two","three"];
  $.ajax({
  
                  type: 'POST',
  
                  url: 'hello.php',
                  data: { name: "saurabh" },
                  success : function(msg) {
  
                      // here is the code that will run on client side after running clear.php on server
  
                      // function below reloads current page
                      alert(msg);
  
                  }
  
  });
  
  });
  </code></pre>
  
  <p>PHP script : </p>
  
  <pre><code>&lt;?php
      $fp = fopen('/Users/saurabh/Desktop/connections.txt', 'w');
      echo "Saving file";
      fwrite($fp, "hello");
      //echo $_POST['yourarray']);
      fclose($fp);
  ?&gt;
  </code></pre>