title: ajax url point to a php function in seperatet file
body: <p>I'm having some problems with ajax (have never been working with it).
  I would like to delete the selected row from the tabel without refreshing the page, and without creating a new file for the query. I'd like to keep all functions in the functions.php if possible?</p>
  
  <p>I have 3 files here.</p>
  
  <ul>
  <li>index.php</li>
  <li>ajax.js</li>
  <li>functions.php</li>
  </ul>
  
  <p>index file:</p>
  
  <pre><code>$res = articles($db);
     foreach($res as $res){
        $id = $res['article_id'];
  
      echo "&lt;form action='' method='post'&gt;";
        echo "&lt;input type=hidden" name='delete' value="&lt;?php echo $id;?&gt;"&gt;
        echo "&lt;input type='submit' name='delete_article'&gt;";
      echo "&lt;/form&gt;";
        }
  </code></pre>
  
  <p>the ajax call</p>
  
  <pre><code>$.ajax({ url: 'HERE I WANT TO RUN THE DELETE FUNCTION FROM FUNCTIONS.PHP',
       data: {action: 'test'},
       type: 'post',
       success: function(output) {
                    alert(output);
                }
  });
  </code></pre>
  
  <p>the function</p>
  
  <pre><code>function delete_article($db){
  
  $id = $_POST['delete'];
  $sql = "DELETE FROM articles WHERE article_id = :article_id";
  $stmt = $db-&gt;prepare($sql);
  $stmt-&gt;bindValue(':article_id',$id);
  $stmt-&gt;execute();
  }
  </code></pre>