Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery ajax call fails when last input is filled
    primarykey
    data
    text
    <p>JQuery noob here,</p> <p>I'm working on a simple web-app which needs to send registration info to a server. For some reason this code works fine when only two of the form inputs are filled in, but fails when there's information in the last one, even though I'm not using it in the code. The error callback gets called, but errorThrown is empty. My server receives no data. </p> <p>Is there anything obviously wrong with this?</p> <p>Note: the call fails when the last input is filled, no matter how many inputs are in the form.</p> <h3>JQuery:</h3> <pre><code>$(document).ready(function() { $("#registrationForm button.register").on("click", function(event) { var params = { email: $("#registrationForm input.email").val(), password: $("#registrationForm input.password").val() }; $.ajax({ url: "/register", type: "POST", contentType: "application/json", data: JSON.stringify(params), dataType: "json", success: function(data, textStatus, jqXHR) { console.log(data); if(data.user_exists==true) { alert("Stop trying to register twice!"); }else{ window.location.href = "/registered"; } }, error: function(jqXHR, textStatus, errorThrown) { console.error("Error:", errorThrown); } }); }); }); </code></pre> <h3>And the HTML:</h3> <pre><code>&lt;form id="registrationForm"&gt; &lt;label&gt;Email:&lt;/label&gt; &lt;input name="user[email]" type="text" required="required" class="email"&gt; &lt;br&gt; &lt;label&gt;Password:&lt;/label&gt; &lt;input name="user[password]" type="password" required="required" class="password"&gt; &lt;br&gt; &lt;label&gt;Verify Password:&lt;/label&gt; &lt;input name="nothing" type="text" required="required"&gt; &lt;br&gt; &lt;button onclick="" class="btn btn-default register"&gt;Register&lt;/button&gt; &lt;/form&gt; </code></pre>
    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.
    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