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

  • Home
  • SEARCH
  • 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 716345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:17:21+00:00 2026-05-14T05:17:21+00:00

I have a problem with the jquery-autocomplete pluging and my django script. I want

  • 0

I have a problem with the jquery-autocomplete pluging and my django script. I want an easy to use autocomplete plugin. And for what I see this (http://code.google.com/p/jquery-autocomplete/) one seems very usefull and easy. For the django part I use this (http://code.google.com/p/django-ajax-selects/) I modified it a little, because the out put looked a little bit weired to me. It had 2 ‘\n’ for each new line, and there was no Content-Length Header in the response. First I thought this could be the problem, because all the online examples I found had them. But that was not the problem.

I have a very small test.html with the following body:

<body>
<form action="" method="post"> 
<p><label for="id_tag_list">Tag list:</label> 
<input id="id_tag_list" name="tag_list" maxlength="200" type="text" /> </p> 
<input type="submit" value="Submit" /> 
</form> 
</body>

And this is the JQuery call to add autocomplete to the input.

function formatItem_tag_list(row) {
    return row[2]
}
function formatResult_tag_list(row) {
    return row[1]
}

$(document).ready(function(){
    $("input[id='id_tag_list']").autocomplete({
        url:'http://gladis.org/ajax/tag',
        formatItem: formatItem_tag_list,
        formatResult: formatResult_tag_list,
            dataType:'text'
    }); 
});

When I’m typing something inside the Textfield Firefox (firebug) and Chromium-browser indicates that ther is an ajax call but with no response. If I just copy the line into my browser, I can see the the response. (this issue is solved, it was a safety feature from ajax not to get data from another domain)

For example when I am typing Bi in the textfield, the url “http://gladis.org/ajax/tag?q=Bi&max… is generated. When you enter this in your browser you get this response:

4|Bier|Bier
43|Kolumbien|Kolumbien
33|Namibia|Namibia

Now my ajax call get the correct response, but there is still no list showing up with all the possible entries. I tried also to format the output, but this doesn’t work either. I set brakepoints to the function and realized that they won’t be called at all.

Here is a link to my minimum HTML file http://gladis.org/media/input.html

Has anybody an idea what i did wrong. I also uploaded all the files as a small zip at http://gladis.org/media/example.zip.

Thank you for your help!

[Edit]
here is the urls conf:

(r'^ajax/(?P<channel>[a-z]+)$', 'ajax_select.views.ajax_lookup'),

and the ajax lookup channel configuration

AJAX_LOOKUP_CHANNELS = {
    # the simplest case, pass a DICT with the model and field to search against :
    'tag' : dict(model='htags.Tag', search_field='text'),
}

and the view:

def ajax_lookup(request,channel):
    """ this view supplies results for both foreign keys and many to many fields """

    # it should come in as GET unless global $.ajaxSetup({type:"POST"}) has been set
    # in which case we'll support POST
    if request.method == "GET":
        # we could also insist on an ajax request
        if 'q' not in request.GET:
            return HttpResponse('')
        query = request.GET['q']
    else:
        if 'q' not in request.POST:
            return HttpResponse('') # suspicious
        query = request.POST['q']

    lookup_channel = get_lookup(channel)

    if query:
        instances = lookup_channel.get_query(query,request)
    else:
        instances = []

    results = []
    for item in instances:
        results.append(u"%s|%s|%s" % (item.pk,lookup_channel.format_item(item),lookup_channel.format_result(item)))

    ret_string = "\n".join(results)
    resp = HttpResponse(ret_string,mimetype="text/html")
    resp['Content-Length'] = len(ret_string)
    return resp
  • 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-14T05:17:21+00:00Added an answer on May 14, 2026 at 5:17 am

    I found a solution, but well I still don’t know why the first approach didn’t worked out. I just switched to a different library. I choose http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/. This one is actually promoted by jQuery and it works 😉

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

Sidebar

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.