Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to implement jquery/ajax into html page
    primarykey
    data
    text
    <pre><code> echo "&lt;form method='post' action='regprocess.php' id='registerform'&gt;"; echo '&lt;fieldset class="register"&gt;'; echo"&lt;h2&gt;Register&lt;/h2&gt;"; echo "&lt;ul&gt;"; echo '&lt;li&gt;&lt;label for="FirstName"&gt;First Name: &lt;/label&gt; &lt;input type="text" name="FirstName" id="FirstName"&gt;&lt;/li&gt;'; echo '&lt;li&gt;&lt;label for="LastName"&gt;Last Name: &lt;/label&gt; &lt;input type="text" name="LastName" id="LastName"&gt;&lt;/li&gt;'; echo '&lt;li&gt;&lt;label for="Email"&gt;Email: &lt;/label&gt;&lt;input type="email" name="Email" id="Email"&gt;&lt;/li&gt;'; echo '&lt;li&gt;&lt;label for="Username"&gt;Username: &lt;/label&gt;&lt;input type="text" name="Username" id="Username"&gt;&lt;/li&gt;'; echo '&lt;li&gt;&lt;input type="button" id="check_username_availability" value="Check Availability"&gt;&lt;/li&gt;'; echo '&lt;div id="username_availability_result"&gt;&lt;/div&gt;'; echo '&lt;li&gt;&lt;label for="Password"&gt;Password: &lt;/label&gt;&lt;input type="password" name="Password" id="Password"&gt;&lt;/li&gt;'; echo '&lt;li&gt;&lt;input type="submit" value="Register"&gt;&lt;/li&gt;'; echo "&lt;/ul&gt;"; echo "&lt;/fieldset&gt;"; echo "&lt;/form&gt;"; } $username = mysql_real_escape_string($_POST['Username']); //mysql query to select field username if it's equal to the username that we check ' $usernameresult = 'Select Username from User where Username = "'. $username .'"'; $uresult = $conn-&gt;query($usernameresult); //if number of rows fields is bigger them 0 that means it's NOT available ' if($uresult-&gt;num_rows==1) { //and we send 0 to the ajax request echo 0; }else{ //else if it's not bigger then 0, then it's available ' //and we send 1 to the ajax request echo 1; } ?&gt; &lt;script src="jquery-1.8.1.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT"&gt; $(document).ready(function() { var checking_html = 'Checking...'; //when button is clicked $('#check_username_availability').click(function(){ //run the character number check if($('#username').val().length &lt; min_chars){ $('#username_availability_result').html(checking_html); check_availability(); } }); }); //function to check username availability function check_availability(){ //get the username var username = $('#username').val(); //use ajax to run the check $.post("check_username.php", { username: username }, function(result){ //if the result is 1 if(result == 1){ //show that the username is available $('#username_availability_result').html(username + ' is Available'); }else{ //show that the username is NOT available $('#username_availability_result').html(username + ' is not Available'); } }); } &lt;/script&gt; </code></pre> <p>Hi everyone, So i'm trying to make a form that will validate if there is a username avaliable in my database. I've kinda of used javascript before, but I haven't done a lot with Ajax and JQuery. I keep getting this error message in the console that says ReferenceError: Can't find variable: $ which responds to this line of script $(document).ready(function() {<br> I'm not really sure why, and I was just wondering if anyone can give me some insight on how to fix it? thank you.</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.
    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