Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Call ajax function on autocomplete in jquery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 540
    Comment on it
    <h2>//Call ajax function on autocomplete in jquery</h2>
    
    
    
    $(document).ready(function(){
    jQuery("#name").autocomplete({
            source: function(request, response) {
                $.ajax({
                    url: 'include/get.php',
                    type: "POST",
                    data: {
                        term : request.term,
                        data :$("#form1").serializeArray()
                    },
                    success: function(data) {
                    data=JSON.parse(data);
                    response(data);
                    } <br>
                });
            },
            minlength:1
        });
    });
    
    Here onclick of name it calls ajax  file get.php where it sends the form data and the entered term  .
    The response we get which is in json format is again parsed as
    data=JSON.parse(data);
    to get the result otherwise it shows jquery error. Means the data is parsed as json twice to display the result in correctly.
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: