Hi,

Am trying to get some data from DB , here am checking whether username is registered or not , if he register am getting some data related to that user and displaying on window .

I want function to wait for untill user finish typing his username ,
then run the function , Below is my code ,

$(function (){  
        var minlength = 2;                        
        $("#username").keyup(function () {
        var that = this,
        value = $(this).val();          
        if (value.length >= minlength ) {
                $.ajax({                
                        type: "GET",
                        url: "Path_to_php",
                        data: {'username' : value},
                        dataType: "html",
                        success: function(data){
                                if (value==$(that).val()) {
                                        $("#content").append("<p>" + data + "</p>");
                                }
                                else {
                                        alert ("Username Not Registered");
                                }
                        }
                });
                }
        });
});

Here , when user start entering his name , that time only Function getting call for each char he entered

Thank you
Pervez

Hey Bachov ,

Thank you ,I treied this before :)

Just to comment:

data: {'username' : value},

Im not sure if that actually works, specially with GET.

I say this because Im doing something similar (also with GET) and I use

data: "parameternametopass="+valueofvariablestopass,   

And it works for me.
On difference is that my datetype is JSON and yours is HTML.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.