title: get data from server with node.js
body: <p>i want to do an ajax call to node.js with get method
  that the result of the ajax call will show in the same html page that i call the ajax function</p>
  
  <p>this is the html code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;title&gt;Sing-in Page&lt;/title&gt;
    &lt;link rel="stylesheet" href="css/style.css"&gt;
    &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
    &lt;script&gt;
      $(function() {
        $("#myform").bind('ajax:complete', function() {
               // tasks to do 
               alert('1');
         });    
      });
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form method="get" action="http://localhost:8080/Login" id="myform" class="login"&gt;
      &lt;p&gt;
        &lt;label for="login"&gt;Email:&lt;/label&gt;
        &lt;input type="text" name="login" id="login" value=""&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;label for="password"&gt;Password:&lt;/label&gt;
        &lt;input type="password" name="password" id="password" value=""&gt;
      &lt;/p&gt;
      &lt;p class="login-submit"&gt;
        &lt;button type="submit" class="login-button"&gt;Login&lt;/button&gt;
      &lt;/p&gt;
      &lt;p class="forgot-password"&gt;&lt;a href="index.html"&gt;Forgot your password?&lt;/a&gt;&lt;/p&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>the is my node.js code, i know that i need to write something in the res.end function but i don't now what..</p>
  
  <pre><code>var express = require('express');
  var app     = express();
  var fs = require("fs");
  var mysql      = require('mysql');
  var pool = mysql.createPool({
      host     : 'XXXX',
      user     : 'XXXX',
      password : 'XXXX',
      database : 'XXXX',
  });
  
  app.use(express.bodyParser());
  
  app.get('/Login', function(req, res) {
      pool.getConnection(function(err, connection) {
          var sql = 'select count(id) as ok from users where email=\''+req.body.login+'\' and password=\''+req.body.password+'\';';
          console.log("query: "+sql);
          connection.query( sql, function(err, rows) {
              console.log(rows[0].ok);
              connection.end();
          });
      });
      // what to write here that res.end() will return the result of console.log(rows[0].ok);
      res.end();
  });
  
  app.listen(8080, function() {
    console.log('Server running...');
  });
  </code></pre>
  
  <p>i want to get the result of the sql query from the DB</p>