Note that there are some explanatory texts on larger screens.

plurals
  1. POPass specific info through JSON, JQuery, PHP
    primarykey
    data
    text
    <p>My PHP:</p> <pre><code>if($count == 1 &amp;&amp; $user_level &lt; 4 &amp;&amp; $if_active == 1) { $response = array("success" =&gt; true); //The login stuff happens here echo json_encode($response); } elseif($count == 1 &amp;&amp; $user_level &lt; 4 &amp;&amp; $if_active == 0) { $response = array("success" =&gt; not_act); echo json_encode($response); } else { $response = array("success" =&gt; false); echo json_encode($response); } </code></pre> <p>The JQuery that sends and recieves the data from that PHP file</p> <pre><code>$('#login_form').submit(function(){ var emailB = encodeURIComponent($('#email_B').val()); var passwordB = encodeURIComponent($('#password_B').val()); $('#wrapper').fadeOut(); $('#login_effect').fadeIn(); $.ajax({ type: 'POST', url: 'checklogin.php', dataType: "json", data: { email: emailB, password: passwordB, }, success: function(result) { if (!result.success) { timeout = setTimeout(function(){ $('#login_effect').fadeOut(); }, 1500); $('#wrong_password').fadeIn(); } else if (result.success == not_act) {timeout = setTimeout(function(){ $('#login_effect').fadeOut(); }, 1500); $('#not_act').fadeIn();} else { timeout = setTimeout(function(){ $('#login_effect').fadeOut(); }, 1500); document.location.href='http://matchmingle.net/profile/'; } } }); return false; }); </code></pre> <p>This works fine and dandy EXCEPT for the not activated part. How do I find out in the JQuery what the JSON returned besides just true and false? I tried to </p> <pre><code>$response = array("success" =&gt; not_act); </code></pre> <p>and then in the JQUery </p> <pre><code>else if (result.success == not_act) {do cool stuff} </code></pre> <p>but I can't get it to work because I'm obviously doing it wrong. BTW I'm very new to this JQuery/JSON/Javascript, what you're seeing me do is what I've learned from a dummies book over the corse of a few weeks and a bunch of help from you guys. </p> <p>So yeah, what's the proper way to set the json response variable and find out what it's value is in the JQuery? Thanks a bunch -Mike</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload