title: PHP Code Returns Its Script and Doesn't Work in JQuery Ajax
body: <p>I would like to do a web site using Aptana IDE and xampp, and it has a few pages. Index page is where all users which does not log in the system and home is where all users which does log in the system must visit. I am very new to develop web site. </p>
  
  <p>I decided to use Ajax for log in sign up pages. It was actually works properly. But now I do not know why it does not. </p>
  
  <p>In my login.html page </p>
  
  <pre><code>&lt;form id="login-form" class="text-left" method="post"&gt;
                  &lt;div class="main-login-form"&gt;
                      &lt;div class="login-group"&gt;
                          &lt;div class="form-group"&gt;
                              &lt;label for="lg_username" class="sr-only"&gt;Username&lt;/label&gt;
                              &lt;input type="text" class="form-control" id="lg_username" name="username" placeholder="username"
                                     data-container="body" data-toggle="popover" data-placement="left" data-content=""
                                     value=""&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group"&gt;
                              &lt;label for="lg_password" class="sr-only"&gt;Password&lt;/label&gt;
                              &lt;input type="password" class="form-control" id="lg_password" name="password" placeholder="password" 
                                     data-container="body" data-toggle="popover" data-placement="left" data-content=""&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group login-group-checkbox"&gt;
                              &lt;input type="checkbox" id="lg_remember" name="lg_remember"&gt;
                              &lt;label for="lg_remember"&gt;remember&lt;/label&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;button type="submit" class="login-button"&gt;Submit&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p>and form validate with JQuery validation</p>
  
  <pre><code>$(document).ready(function () {
          $('#login-form').validate({
      rules: { //rules goes here},
      messages: { //messages goes here},
      submitHandler: submitForm
  });
  </code></pre>
  
  <p>It works correctly. All my rules are implemented.</p>
  
  <p>submit function:</p>
  
  <pre><code>function submitForm(){
              var username = $('#lg_username').val();
              var password = $('#lg_password').val();
              var checkbox = $('#lg_remember').is(":checked");
  
              var strAjax = "username=" + username + "&amp;password=" + password + "&amp;checkbox=" + checkbox;
              alert(strAjax);
              $.ajax({
                  type: 'POST',
                  url: 'loginAjax.php',
                  data: strAjax,
                  cache: false,
                  success: function(data) {
                      alert(data);
                      if(data == "1") {
                          window.location.href = "home.php";
                      }
                      else {
                          //Error messages
                      }
                  }
              });
              return false;
              }
  </code></pre>
  
  <p>loginAjax.php file: </p>
  
  <pre><code>&lt;?php
  require_once 'dbcon.php';
  session_start();
  
  $username = mysql_real_escape_string($_POST["username"]);
  $password = mysql_real_escape_string($_POST["password"]);
  
  $sql = "SELECT * FROM tbl_user WHERE userName = '$username' AND password = '$password'";
  
  $result = mysql_query($sql);
  $count = mysql_num_rows($result);
  $row = mysql_fetch_array($result);
  
  if($count == 1){
      if($_POST['checkbox'] == TRUE) {
          if(!isset($_COOKIE['name'])) {
              setcookie( 'name', $row['userName'], time() + (86400 * 30) );
          }
      }
      $_SESSION['user_session'] = $row['userName'];
      echo TRUE;
  }
  else {
      echo FALSE;
  }
  ?&gt;
  </code></pre>
  
  <p>dbcon.php file connect to mysql database. I try to control is it enter the ajax method or what is returning from php file with alert. strAjax seems correct but alert(data) show my php code like this;</p>
  
  <p><a href="http://i.stack.imgur.com/Q3HPr.jpg" rel="nofollow">php returns this</a></p>
  
  <p>I change login file as php file instead html. But the problem is not about it. All my ajax codes get data from php something like that. In my computer php files run normally. If you need more information I can edit my post. Why this ajax conk?</p>