title: How to pass variables back from php by ajax
body: <p>I have script from login page which through ajax sends data into php, and php returns if successful or not, I just wonder how can I change my scripts so it would send back also 2 variables and receive it in my login js script so I can create cookies? here are my js and php scripts:</p>
  
  <p><strong>js</strong>:</p>
  
  <pre><code>$(document).on('pageinit',function(){
          $("#login").click(function(){
  
              username=$("#usr").val();
              password=$("#psw").val();
              $.ajax({
                  type: "POST",
                  url: "http://imes.***********.com/php/login_check.php",
                  data: "name="+username+"&amp;pwd="+password,
                  success: function(html){
                      //in case of success
                      if(html=='true')
                      {
                          $("#login_message").html("Logged in, congratulation.");
                          $.mobile.changePage("http://imes.***********.com/userpanel.php");
                      }
                      //in case of error
                      else
                      {
                          $("#login_message").html("Wrong username or password");
                      }
                  },
                  beforeSend: function() { $.mobile.showPageLoadingMsg(); }, //Show spinner
                  complete: function() { $.mobile.hidePageLoadingMsg() } //Hide spinner
              });
              return false;
          });    
  </code></pre>
  
  <p><strong>php</strong>:</p>
  
  <pre><code>&lt;?php
  session_start();
      $username = $_POST['name'];
      $password = $_POST['pwd'];
      include('mysql_connection.php');
      mysql_select_db("jzperson_imesUsers", $con);
  
      $res1 = mysql_query(
       "SELECT * FROM temp_login WHERE username='$username' AND password='$password'"
       );
  
      $num_row = mysql_num_rows($res1);
      if ($num_row == 1) {
          echo 'true';
      }
       else {
          echo 'false';
      }
  ?&gt;
  </code></pre>