Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery AJAX successful but no response given
    primarykey
    data
    text
    <p>I have problems with displaying the response of php in my html, if statements are not running for some reason.</p> <p>The PHP echo's are not recognized by success function.</p> <p><strong>jQuery</strong></p> <pre><code>&lt;script&gt; $(document).ready(function(){ $("#login").submit(function(e){ e.preventDefault(); $.ajax({ type:"POST", url:"logincheck.php", data:$("#login").serialize(), success:function(data){ if(data == "Niet oke"){ $("#status").html('Wachtwoord of username onjuist'); } if(data == "Oke"){ $("#status").html('Mooi'); } } }); }); }); &lt;/script&gt; </code></pre> <p>The HTML file</p> <p><strong>HTML</strong></p> <pre><code>&lt;form id="login"&gt; &lt;input type="text" name="username" placeholder="Username" /&gt; &lt;input type="password" name="password" placeholder="Password" /&gt; &lt;input type="submit" name="submit" value="Submit" /&gt; &lt;/form&gt; &lt;span id="status" style="color:black"&gt;&lt;/span&gt; </code></pre> <p>*Added the logincheck.php file, added the suggestion for header.</p> <p><strong>PHP</strong></p> <pre><code>&lt;?php header("Content-type: application/json"); include_once("includes/dbcon.php"); include_once("pass_system.php"); if(!empty($_POST["username"]) &amp;&amp; !empty($_POST["password"])){ $username = $_POST["username"]; $password = $_POST["password"]; $statement = $dbconnect-&gt;prepare("SELECT * FROM login WHERE username= :username"); $statement-&gt;execute(array(":username" =&gt; $username)); while($row = $statement-&gt;fetch()){ $salt1 = substr($row["password"], 0, 10); $salt2 = substr($row["password"], -10); if(pwhash($password, $salt1, $salt2) === $row["password"]){ header("location: status.php"); echo "Oke"; } } }else{ echo "Niet oke"; } ?&gt; </code></pre>
    singulars
    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.
    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