title: Call PHP function from AMD module moodle
body: <p>For moodle development I want to load an AMD module:</p>
  
  <pre><code>$this-&gt;page-&gt;requires-&gt;js_call_amd('mod_newmodule/testamd', 'init', array($content));
  </code></pre>
  
  <p><code>testamd.js</code> looks like this:</p>
  
  <pre><code>define(['jquery'], function ($) {
  return {
      init : function(content) {
          $(".myclass").click(function () {
                  alert("test");
              });
          }
  };    
  });
  </code></pre>
  
  <p>Instead of <code>alert()</code>, I want to do a database query on button click. How can I call a php function (which does the query) from my AMD module? Or should it be written inside AMD? But then again how? Is there something like a best practice?</p>
  
  <p>Besides I don't get to where the <code>init</code> is returned. </p>
  
  <pre><code>$var = $this-&gt;page-&gt;require-&gt;...
  </code></pre>
  
  <p>Nothing returned to <code>$var</code>?</p>
  
  <p>Thanks for your help.</p>