title: jQuery AJAX call PHP Class function
body: <p>I wrote an user action analysis but I can't execute my <code>insert into</code> statement. I tried all suggestion on stack can't but figure out my mistake, I don't even get an error: it is running through without executing the statement. I have also an connection php - this works fine so the fault is not there. I would like to insert the <code>action</code> var later but at first I have to call the function. So whats wrong with my request or php function? </p>
  
  <p><strong>jQuery</strong></p>
  
  <pre><code>$( document ).ready(function() {
    var action = '';
    document.addEventListener('click', function(e) {
      e = e || window.event;
      e = e.target || e.srcElement;
      if (e.nodeName === 'SECTION') {
        action = e.id;
        updateAction();
      }
    }, false);
  
    function updateAction() {
      $.ajax({
        type: "POST",
        url: '../actions/userAction.php',
        data: {action: 'test'},
        success: function(){
          console.log(action);
        }
      });
    }
  });
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
  class userAction
  {
    /* User Action */
    public function updateAction(){
      if(isset($_POST['action']) &amp;&amp; !empty($_POST['action'])) {
        $db = getDB();
        $st = $db-&gt;prepare("INSERT INTO user_analysis (action) VALUES ('bla') where userID = 1945");
        $st-&gt;execute();
        $db = null;
        $_SESSION['uid']=$uid;
        return true;
      }    else
      {
        return false;
      }
    }
  }
  ?&gt;
  </code></pre>