Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6955065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:41:18+00:00 2026-05-27T14:41:18+00:00

How do i use jquery autocomplete ? will you please help me ? thank

  • 0

How do i use jquery autocomplete? will you please help me ? thank you

UPDATE: I have written following view. Which works just fine without ajax. Now I want to integrate with ajax. I tired alot. But found no luck. I need your help. Thank you guys

UPDATED views.py

def search(request):
errors = []
if 'q' in request.GET:
    q = request.GET['q']
    if not q:
        errors.append('Enter a search term.')
    else:

        categories = UserProfile.objects.filter(user=request.user)[0]
        languages = categories.language.all()

        movies = Movie.objects.filter(title__istartswith=q,language__in=languages)
        results = [ x.title for x in movies ]
        json = simplejson.dumps(results)
        return HttpResponse(json, mimetype="application/json")

my form

<form action="/search/" method="get">
    <input type="text" name="q" id ="q">
    <input type="submit" value="Search">
</form>

UPDATE3: When I use following ajax function. It worked. Its displaying the data in terminal. But the problem is that its not showing list of movies in input field.

enter image description hered

my ajax

    <script>
   $(document).ready(function() {  
    $("#q").autocomplete("/search/");  
});
    </script>

UPDATE 4: I’ve just changed the code. Now its displaying the contents in one line. Here is screenshot.
enter image description here

UPDATE 5: When I use this return HttpResponse(json, mimetype="plan/text") it worked. but the problem is same (all contents in one line). If i use return HttpResponse(json, mimetype="application/json") It does not work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:41:18+00:00Added an answer on May 27, 2026 at 2:41 pm

    You are using ‘q’ as the get string, but the jquery autocomplete widget expects it to be called ‘term’. You need to make the following change at the start of your view:

    if 'term' in request.GET:
        q = request.GET['term']
        if not q:
            errors.append('Enter a search term.')
        ...
    

    Edit: The next part of the answer was added before the OP updated their question and json encoded the results.

    You can’t just return a queryset of movies — it has to be in a format that the autocomplete widget can understand. The easiest thing is to return a list of names (the same as in example you tried with programming languages. The end of your view should look something like this:

    # import at the top of your views.py
    from django.utils import simplejson
    ...
    movies = Movie.objects.filter(title__istartswith=q,language__in=languages)
    results = [ x.title for x in movies ] # this is good, you didn't need to comment it out!
    # now encode the results as json, and return them
    return HttpResponse(simplejson.dumps(results), mimetype="application/json")
    

    See how you get on with that, and leave a comment if you’re still having trouble.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have use rails3-jquery-autocomplete plugin and I am just wondering how can I use
I use jquery.autocomplete , which uses a javascript regexp to highlight substrings in the
I'm struggling with the following problem. I use the jQuery autocomplete plugin to get
I am using jQuery autocomplete pluggin . I have the following code $().ready(function() {
I am trying to use jQuery's fancy autocomplete function but I have a problem
I am trying to use jquery autocomplete plugin, I want it to suggest ItemCodes
When I use JQuery's autocomplete and hardcode the array values in the page it
I'm trying to use JQuery's autocomplete plug-in but for some reasons Internet Explorer is
I want to use autocomplete (jquery or .net) with force a choice so that
im trying to use the jQuery UI autocomplete to communitate with a webservice with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.