title: Trying to call PHP function using jQuery.post()
body: <p>Here is my <code>index.php</code>:</p>
  
  <pre><code>&lt;?php
  function type_my_text(){
      echo filter_input(INPUT_POST, 'textfield')
  }
  
  $action = filter_input(INPUT_POST, 'action');
  if($action == "typer"){
      type_my_text();
  }
  ?&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;script src="js/jquery.js"&gt;&lt;/script&gt;
          &lt;script&gt;
              function call_typer(){
                  $.post('index.php', {action : "typer"});
              };
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form name="form" method="POST" action="index.php"&gt;
              &lt;input type="text" name="textfield"&gt;
              &lt;input type="submit" value="type" onclick="call_typer()"&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>With this code, I'm trying to call <code>type_my_text</code> PHP function using ajax (<code>post()</code>, in the case) when I click the submit button. I mounted this code based on other answers, but It isn't working and I don't know what I'm missing.</p>
  
  <p>The process:</p>
  
  <p><code>html button click</code> -> <code>call js call_typer() function</code> -> <code>make jQuery.post() ajax request</code> -> <code>php var $action receive "typer"</code> -> <code>call php function type_my_text()</code></p>
  
  <p>I'm expecting that this code writes on page what I wrote in the textfield. When I submit the button, nothing happens. I think the ajax request is happening, but <code>filter_input(INPUT_POST, 'action')</code> is receiving nothing or not what I'm expecting (<code>"typer"</code> as value).</p>
  
  <p>No error is being raised.</p>