title: Jquery Ajax not assigning the returned valued from php
body: <p>im Daniel from South america, and i really needed help, i have been looking for this problem but i have had no luck so far, a brief explanation would be, I use ajax to validate a login, It works, then all of a sudden after just a few tests runs, the ajax just doesnt work and i have to do a whole new project just for the same code to work again, just to break again. </p>
  
  <p>This one is a real basic login that i built fast to test the Ajax code, like i said, the really basic "validation" worked 2 to 3 times and then it just stopped working, also the navbar.php includes the working navbar and the bootstrap </p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
          &lt;html lang="en"&gt;
          &lt;head&gt;
              &lt;?php include "navbar.php";
  
              ?&gt;
  
              &lt;meta charset="utf-8"&gt;
              &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt;
              &lt;link rel="stylesheet" href="estilos.css"&gt;
          &lt;/head&gt;
          &lt;body&gt;
  
          &lt;form id="login" method="post" onsubmit="SubmitHandler()"&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for="exampleInputEmail1"&gt;Email address&lt;/label&gt;
                  &lt;input type="email" class="form-control" id="email" name="email"aria-describedby="emailHelp" placeholder="Enter email"&gt;
                  &lt;small id="emailHelp" class="form-text text-muted"&gt;We'll never share your email with anyone else.&lt;/small&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label for="exampleInputPassword1"&gt;Password&lt;/label&gt;
                  &lt;input type="password" class="form-control" id="password" name="password" placeholder="Password"&gt;
              &lt;/div&gt;
              &lt;div class="form-check"&gt;
                  &lt;label class="form-check-label"&gt;
                      &lt;input type="checkbox" class="form-check-input"&gt;
                      Check me out
                  &lt;/label&gt;
              &lt;/div&gt;
              &lt;button type="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;
          &lt;/form&gt;
          &lt;script type="text/javascript"&gt;
              function SubmitHandler() {
                  var email = $('#email').val();
                  var password = $('#password').val();
                  $.ajax({
                      type: "POST",
                      url:"procesado.php",
                      data: {'email':email,
                          'password':password},
                      cache: false,
                      success: function(data) {
                          alert(data);
                          if(data==true){
                              alert("Es Correcto/Valid");
                          }
                          else{
                              alert("es Incorrecto/Invalid");
                          }
                      }
                  });
              }
  
          &lt;/script&gt;
          &lt;/body&gt;
          &lt;/html&gt;
  </code></pre>
  
  <p>The following one is the php called Procesado, and it just connects to the DB where the main details are on the bd.php thats included_once and compares the first input (email) and second (password) to the DB and returns either True or false</p>
  
  <pre><code>  &lt;?php
          include_once 'bd.php';
          /**
           * Created by PhpStorm.
           * User: Phsic
           * Date: 26-Sep-17
           * Time: 8:47 PM
           */
  
          $email = mysqli_real_escape_string($conn,$_POST['email']);
          $password = mysqli_real_escape_string($conn,$_POST['password']);
          $url = $_SERVER['HTTP_REFERER'];
          $sql = "SELECT * FROM usuario WHERE correo_usuario = '' AND clave_usuario = 'lalass'";
  
          $result = mysqli_query($conn, $sql);
  
          $count = mysqli_num_rows($result);
          $row = mysqli_fetch_array($result);
          if($count == 1){
              $_SESSION['user_session'] = $row['correo_usuario'];
              echo true;
          }
          else {
              echo false;
          }
          exit;
          ?&gt;
  </code></pre>
  
  <p>I really dont know what else to try, i have rewritten this code, viewed different guides online, and it always breaks after some uses, if anyone wonders what the Alert(data) returns on the first code, it just skips it entirely and goes directly to alert("es Incorrecto/Invalid"); Thanks in advance and sorry for both my broken english and the poorly idented Code, im a beginner and im really enthusiast about all of this.</p>