Jump to content

Recommended Posts

hi

i need help in adding preloader to ajax code. in the following code i want to add preloader when user clicks on Tab One and also when user enter its username and password and after pressing submit button there i want to add preloader. i have a loader.gif image so please help me how and where can i add it

loginTab.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
        <link rel="stylesheet" href="style.css"/>
    </head>

    <body>
        <div class="tabs" onclick="tabOne()">Tab One</div>
        <div id="message"></div>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
        <script type="text/javascript" src="script.js"></script>
    </body>
</html>

 

script.js

function tabOne() {
    $('div#message').load('login.html');
}
function login () {
    var url = 'login.php';
    var user = $('input#user').val();
    var pass = $('input#pass').val();

    var queryString = 'user=' + user + '&pass=' + pass;

    $.post(url,queryString,display);
    function display(data) {
        $("#content").html(data);
    }
}

 

login.html

<div id="content"></div>
<form>
    Username:<br />
    <input type="text" name="user" id="user" /><br />
    Password:<br />
    <input type="password" name="pass" id="pass" /><br />
    <input type="button" name="submit" id="submit" value="Login" onclick="login()" />
</form>

 

login.php

<?php
$email = strip_tags($_POST['user']);
$password = strip_tags($_POST['pass']);

//echo $email;
//echo $password;

if($email&&$password) {

    $connect = mysql_connect("localhost","user","pass");
    mysql_select_db("facebook");
    $query = mysql_query("SELECT email FROM users WHERE email='$email'");
    $count = mysql_num_rows($query);
    if($count == 0) {
        echo "You are registered thanks.";
    }
    else {
        die("That email address already exist.");
    }
}
else {
    die("please fill in both fields!");
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.