Create a jQuery variable from a PHP script?
<p>I'm working on a login script, and I want to send the input to a PHP script, check it, and then do something if it matches the one I have in the config.php file.</p>

<p>pseudo php code (admin_login.php)</p>

<pre><code>&lt;?php
require("../config.php");
if($_POST['password'] == $password) {
    $showLoginPage = true;
    }
    else {
     $showLoginPage = false;
    }
?&gt;
</code></pre>

<p>jQuery:</p>

<pre><code> $("#admin_login_submit").click(function(event) {
     event.preventDefault();
     var pass = $("#admin_login_password").val();
     $.post("includes/process/admin_login.php",
          { password: pass },
        function(data){
        $("#show_admin_feedback").html(data);
     });
</code></pre>

<p>If I could magically create jQuery code, what I want to do would look like this:</p>

<pre><code>$("#admin_login_submit").click(function(event) {
     event.preventDefault();
     var pass = $("#admin_login_password").val();
     $.post("includes/process/admin_login.php",
          { password: pass },
        function(data){
        $("#show_admin_feedback").html(data);
        showLoginPage = $showLoginPage;
     });
      if(showLoginPage == true) {
       $("#main").load("logged_in.php");
      }
  });
</code></pre>

<p>Oh, I have <code>$("#show_admin_feedback").html(data);</code> being returned because I was returning "Worked" or "Didn't work" when I was testing it. :-p.</p>

<p>------Fixed. Thanks, jitter!</p>

<p>php</p>

<pre><code>&lt;?php
require("../config.php");
if($_POST['password'] == $password) {
    header('HTTP/1.1 200 OK');
    }
    else {
     header('HTTP/1.1 404 Not Found');
    }

?&gt;
</code></pre>

<p>jQuery</p>

<pre><code>$("#admin_login_submit").click(function(event) {
     event.preventDefault();
     var pass = $("#admin_login_password").val();
     $.ajax({
      type: "POST",
      url: "includes/process/admin_login.php",
      data: "password=" + pass,
      success: function(){
        $("#main").load("logged_in.php"); },
      error: function(){
       $("#admin_login_show").html("&lt;b&gt;Failed Login&lt;/b&gt;"); }
     });
  });
</code></pre>
