title: AJAX call to Node.js script fails
body: <p>I am very new to Node.js so I am certain I am doing something basic wrong. I am trying to make an AJAX call using jQuery to a simple Node.js script. I have tried several variations on the call, using both <code>$.post</code> and <code>$.ajax</code>, and I have done a couple of different things with the Node.js script, but I keep getting a 404 response on the call. I have looked at several posts about this error, but I haven't found anything which gets me away from the 404 error my AJAX call returns.</p>
  <p>This is the AJAX call:</p>
  <pre><code>$.ajax({
      url: &quot;/myapp&quot;,
      type: &quot;GET&quot;,
      success: function(cardResponse) {
          console.log(cardResponse);
      }
  });
  </code></pre>
  <p>I would prefer to use POST, but I tried GET in hopes it would make a difference. I didn't think it would, and I was right.</p>
  <p>Here's the Node.js script:</p>
  <pre><code>#!/opt/rh/rh-nodejs8/root/bin
  
  const express = require('express');
  const app = express();
  
  app.post('/myapp', function (req, res) {
      res.json([{
          id_number: 1234,
          user_name: &quot;Andy&quot;
      }]);
      console.log(&quot;Meow&quot;);
  });
  
  app.get('/myapp', function (req, res) {
      res.json([{
          id_number: 1234,
          user_name: &quot;Andy&quot;
      }]);
      console.log(&quot;Meow&quot;);
  });
  
  app.listen( () =&gt; {
      console.log(`Server is running.`);
  });
  </code></pre>
  <p>I have tried specifying a port on the listen and in the AJAX call. (I read you're not supposed to do that in an AJAX call, but I saw at least one post where someone did so, so I tried it.) On the server, I start the Node.js as expected:</p>
  <p><code> # node app.js</code></p>
  <p>What am I doing wrong here? Any advice would be appreciated. I apologize if the answer is already posted somewhere and I missed it in my search for an answer.</p>