0

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

3
Contributors
3
Replies
6
Views
4 Years
Discussion Span
Last Post by riahc3
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.