Posts

Showing posts with the label AJAX

Scroll to top after Ajax content load

Just use the scroll function scrollTo ( 0 ); If you want the jquery, then  here is a good example with smoothing  :) From the link: $ ( 'html, body' ). animate ({ scrollTop : 0 }, 0 ); //nice and slow :) $ ( 'html, body' ). animate ({ scrollTop : 0 }, 'slow' ); To put it in your code ... success : function ( msg ) { $ ( "#view-area" ). html ( msg ); $ ( "#loader" ). fadeOut (); //Put code here like so $ ( 'html, body' ). animate ({ scrollTop : 0 }, 0 ); }

PHP Ajax Login Validation Tutorial

Image
This post explains you about php login with ajax. In this example, first of all we will validate the user details using ajax library and showing the appropriate result. If user enter correct detail (ie:- admin/admin in this example)we will be redirected to the “index.php” and if you will try to directly access “index.php” means without entering the user details you will redirected to “login.php”. Download Link    Demo Link Sample database design for table name contact. This table contains id (primary key), name and age. CREATE TABLE IF NOT EXISTS `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uname` varchar(50) NOT NULL `password` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) dbConnect.inc.php Contains database connectivity code $mysql_db_hostname = "Host name"; $mysql_db_user = "UserName"; $mysql_db_password = "Password"; $mysql_db_database = "Database Name"; $con = mysql_connect($mysql_db_hostname, $mysql_db_user, ...

basic php mysql login script without page reload

insert.php <?php     define('HOST','localhost');     define('USERNAME', 'root');     define('PASSWORD','');     define('DB','mydba');     session_start();     $con = mysqli_connect(HOST,USERNAME,PASSWORD,DB);         $username = $_POST['username'];     $pass = $_POST['password'];         //$_SESSION["username"] = $username;                 //$sql = "select * from users where username='$username' && password='$pass'";         //if(mysqli_query($con, $sql)){         //echo 'success';         //echo "   username is " . $_SESSION["username"] . ".";     //}         $sql="SELECT * FROM users WH...

N-Level of Dynamic Loading of DropDowns using Ajax and PHP. Part 2

Image
This is version 2 of my previous tutorial which was dynamic loading of combos with Ajax . But its much more than that. Its now for n-level dropdowns, I mean if you have parent-child records untill n-level and you want to load them using dropdowns with ajax. It is my favorit tutorial and very useful for any one. We often needs ajax loading of dropdowns and this is for n-level records. Hope you will like it. Cheers ! PHP $(document).ready(function() { //$('#loader').hide(); $('.parent').livequery('change', function() { $(this).nextAll('.parent').remove(); $(this).nextAll('label').remove(); $('#show_sub_categories').append(' '); $.post("get_chid_categories.php", { parent_id: $(this).val(), }, function(response){ setTimeout("finishAjax('show_sub_categories', '"+escape(response)+"')...

Ajax Tutorial: Dynamic Loading of ComboBox using jQuery and Ajax in PHP

Image
Here is a script for beginners to create a dynamic loading of dropdown. Simple solution which is created by jQuery. PART TWO IS HERE [ad#ad-3] Table Structure PHP CREATE TABLE IF NOT EXISTS `ajax_categories` ( `id` int(11) NOT NULL AUTO_INCREMENT, `category` varchar(50) NOT NULL, `pid` int(11) NOT NULL, PRIMARY KEY (`id`) ) 1 2 3 4 5 6 CREATE TABLE IF NOT EXISTS ` ajax_categories ` (    ` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,    ` category ` varchar ( 50 ) NOT NULL ,    ` pid ` int ( 11 ) NOT NULL ,    PRIMARY KEY ( ` id ` ) ) get_child_categoires.php PHP ID= "> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <?php if ( $_REQUEST ) { $id = $_REQUEST [ 'parent_id' ] ; $query = "select * from aj...

PHP Captcha using jQuery AJAX Contact form (sent data to mail)

Image
Captcha code in a form is used for ensuring that the form is submitted with manual intervention without any tools or programs. In this tutorial, we are using jQuery AJAX for getting captcha image from PHP. Using jQuery we can also refresh the captcha code by resending AJAX call to generate new captcha image. View Demo Download      Contact Form with Captcha This code is for displaying contact form with refreshable captcha image. <div id = "frmContact" > <div> <label style = " padding - top : 20px ; " > Name </label> <span id = "userName-info" class = "info" ></span><br/> <input type = "text" name = "userName" id = "userName" class = "demoInputBox" > </div> <div> <label> Email </label> <span id = "userEmail-info" class = "info" ></span><br/> <i...