title: Simple button click example with Ajax and Node.js?
body: <p>I am new to both Ajax and Node.js + Express. At this point I am trying to figure out how to communicate with both the front and back end through buttons.</p>
  
  <p>I have a button on an HTML page which I would like to use to call a function from the backend and output text to the client.</p>
  
  <p>Here is what I've pieced together for what I need but I am looking for an example on how this could be done.</p>
  
  <p><em>This is all happening on /page</em></p>
  
  <p><strong>index.hjs file</strong></p>
  
  <pre><code>&lt;button class="btn btn-success" onclick="install()"&gt;Install&lt;/button&gt;
  
  // Client Side Ajax Script
  &lt;script&gt;
      $('button').click(function () {
          $.post('/page', {data: 'blah'}, function (data) {
          console.log(data);
        });
      }, 'json');
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>app.js file</strong></p>
  
  <pre><code>app.post('/page', function (req, res, next) {
    calling.aFunction();
    res.write('A message!');
  });
  </code></pre>
  
  <p>Are these all the parts that I need and what needs to be edited to get this functionality to work?</p>