title: Call Php Function From AJAX Not Working
body: <p>I am trying to call a PHP function using AJAX. Below is the script I used.</p>
  
  <pre><code>&lt;script type="text/javascript" src="jquery.1.4.2.js"&gt;
  
      $(document).ready(function () { 
  
                 // after EDIT according to 
                 // @thecodeparadox answer
  
         $('#local').click(function(e){
              e.preventDefault();
              e.stopPropagation();
              promptdownload();
         });
      });
  
          function promptdownload(e) 
          {
          $.ajax({
               type: "POST",
               url: "js/prompt.php",
               data: { "get" : "runfunction", "action" : "promptlocal" },
               success: function (response) {
               }    
           });
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>The corresponding PHP code (prompt.php) is:</p>
  
  <pre><code>&lt;?php
  $path1 = "downloads/1.jpg";
  $browserFilename1 = "Local Travel";
  $mimeType1 = "image/jpeg";
  
  
  function promptToDownload($path, $browserFilename, $mimeType)
  {
  
      if (!file_exists($path) || !is_readable($path)) {
  
          return null;
      }
  
      header("Content-Type: " . $mimeType);
      header("Content-Disposition: attachment; filename=\"$browserFilename\"");
      header('Expires: ' . gmdate('D, d M Y H:i:s', gmmktime() - 3600) . ' GMT');
      header("Content-Length: " . filesize($path));
      // If you wish you can add some code here to track or log the download
  
      // Special headers for IE 6
      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
      header('Pragma: public');
      $fp = fopen($path, "r");
      fpassthru($fp);
  }
  
  if ($_POST["action"] = 'promptlocal')
  {
      promptToDownload($_GET[$path1], $browserFilename1, $mimeType1);//comments
  }
  
  ?&gt;
  </code></pre>
  
  <p>This is how I code the button that is supposed to trigger the function:</p>
  
  <pre><code>&lt;input type="button" id="local" name="local" value="Local Travel"&gt;
  </code></pre>
  
  <p>My expected output is to have this button promt the user: <strong>"where to save 1.jpg file"</strong>.</p>
  
  <p>However I couldn't make it work.</p>
  
  <p>Any advise is highly appreciated.</p>