title: Ajax not working with Node js - Express js
body: <p>Im trying to send data from my server side to my client side with ajax but when i use res.send(data) in node, it show me a empty html with the data and i want to get data from my client side without reloading the page and edit something in my actual html</p>
  
  <p>Here's my server-side code </p>
  
  <pre><code>    app.post('/',(req,res)=&gt;{
      var userName = req.body.username;
      var password = req.body.password;
  
      connection.query('SELECT * from admin',(err, rows, fields)=&gt; {
        if (!err){
          if((userName == rows[0].usuario) &amp;&amp; (password == rows[0].contraseña)){
              res.sendStatus(200);    
  
          }else{
              res.send('Incorrect username or password')
          }
        }else{
          res.send('Error while performing Query.');
        }
  
      });
  
  });
  </code></pre>
  
  <p>Here's my client-side code</p>
  
  <pre><code>$(document).ready(function(){
  $('#login-form').submit(function (e) {
          setTimeout(function () {
          e.preventDefault();
          $.ajax({
              type: 'POST',
              url: '/',
              dataType: 'jsonp',
              data: ({username: $('input[name=username]'),password: $('input[name=password]')}),
              success: function(data,textStatus){
                  if(textStatus.statusCode == 200) {
                      $('.error-user').html('Succes');    
                  }else{
                      $('.error-user').html('Not Success');
                  }
  
  
              },
          });
          }, 1000);
  
  });       
  });
  </code></pre>
  
  <p><strong>UPDATE: I removed the setTimeOut() but when I submit the form the page freeze like two seconds and then nothing happen, I get this 'error Maximum call stack size exceeded', dont get me data just stay in the same view if like post method was never called</strong></p>
  
  <p><strong>UPDATE-FINAL: I got values from input outside of the ajax and it works nice,thanks :#</strong></p>