title: ajax to run php file
body: <p>I have this script in a .html file on my page and im trying to just run the getip.php file from here rather than to rename the file to .php.  I tried this ajax call but its not working and not logging the ip in the logfile.txt.  Please let me know what I am doing wrong.</p>
  
  <p><strong>Ajax in the head of the .html file:</strong></p>
  
  <pre><code> &lt;script&gt;
      $(document).ready(function() {
           $.ajax({
  
                  type: "GET",
                  url: "getip.php",
  
              }); // Ajax Call
          }); //event handler
     &lt;/script&gt;
  </code></pre>
  
  <p><strong>Code from getip.php:</strong></p>
  
  <pre><code>&lt;?php
  // location of the text file that will log all the ip adresses
  $file = 'logfile.txt';
  
  // ip address of the visitor
  $ipadress = $_SERVER['REMOTE_ADDR'];
  
  // date of the visit that will be formated this way: 29/May/2011 12:20:03
  $date = date('d/F/Y h:i:s');
  
  // name of the page that was visited
  $webpage = $_SERVER['SCRIPT_NAME'];
  
  // visitor's browser information
  $browser = $_SERVER['HTTP_USER_AGENT'];
  
  // Opening the text file and writing the visitor's data
  $fp = fopen($file, 'a');
  
  fwrite($fp, $ipadress.' - ['.$date.'] '.$webpage.' '.$browser."\r\n");
  
  fclose($fp);
  ?&gt;
  </code></pre>