AutoComplete With Django
Hi there,
Sorry for posting this question even it had been answered but i tried
all my best to solve this issue,
if use result list in Jquery code directly it works.
Here is code,
HTML:
<form method = "get">
<fieldset>
<label for="searchbox">Type Something:</label>
<input id="searchbox" type="text" name="n" />
</fieldset>
</form>
Jquery:
$(document).ready(function(){
$("#searchbox").autocomplete({
source: '{% url AutoCompleteSearch %}',
minLength: 2
});
});
View.py:
def AutoCompleteSearch(request):
#query = request.Get.get("q","")
#For Testing
results = []
results = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy blah",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
]
json = simplejson.dumps(results)
return HttpResponse(json, mimetype='application/json')
url.py:
url(r'^AutoCompleteSearch/$', AutoCompleteSearch),
Your help would greatle be appreciated.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home