title: How to use assign php variables from Javascript variable through a function. Values are not determined from html elements
body: <p>I don't see how this would be possilbe using AJAX. The variable I am trying to get doesn't come from an html element, but from predetermined variables. After two variables are set, this code executes which is a function:</p>
  
  <pre><code>// javascript function
  function writetofile(file_name, api, wellname){
      &lt;?php
        //something along the lines of this:
        $file_handler = fopen(file_name, "r");
        $api = api;
        $wellname = wellname;
        $result = $api." : ".$wellname;
        fwrite($file_handler, $result);
        $fclose($file_handler);
      ?&gt;   
  }
  </code></pre>