title: Node.js send data to backend with AJAX
body: <p>I'm quite new to AJAX, so sorry for potential missunderstandings, but I'm not completely through that thing.</p>
  
  <p>I'm trying a simple thing. I have a <code>server.js</code> file, which is my backend basically. Then I have a <code>index.html</code> and a <code>script.js</code>. That's all, so a very basic setup. Now, on my <code>script.js</code>, I'm getting some data (a mail address). Now I want to send that data to my backend (into the <code>server.js</code>) to work with it there. How can I do this?</p>
  
  <p>I found some posts already about AJAX with node.js, but I don't get it, especially not where to receive it in my backend. I'm using express for the server by the way.</p>
  
  <p>What I have in my <code>script.js</code> is:</p>
  
  <pre><code>$.ajax({
              type: "POST",
              url: "server.js",
              data: { mail: mail },
              success: function(data) {
              },
              error: function(jqXHR, textStatus, err) {
                  alert('text status '+textStatus+', err '+err)
              }
          });
  </code></pre>
  
  <p>Right so far? How can I now receive the information in my <code>server.js</code>?</p>
  
  <p>There's not much in so far, just:</p>
  
  <pre><code>var express = require('express');
  
  var app = express();
  var server = app.listen(3000);
  
  app.use(express.static('public'));
  </code></pre>
  
  <p>Thanks for any help :)</p>