I'm send a list from Django(Python) to jQuery, but it is throwing some error while receiving it?
Here is what I send in python.
hubcode_list = ['a','b']
ctx = {'form':form, 'hubcode_list' : hubcode_list, 'admin_permission' : admin_permission}
return render(request, 'dummy/config.html', ctx)
jQuery:-
var hubcode_list = {{ hubcode_list }}
It returns an error saying :-
SyntaxError: syntax error
var hubcode_list = ['a', 'b']
When I use escapejs as
var hubcode_list = {{ hubcode_list|escapejs }}
it throws
SyntaxError: illegal character
var hubcode_list = [\u0027a\u0027, \u0027b\u0027]
How do I receive a list from server(Python)? I need to implement an autocomplete functionality where I need to pass a list of tags.
$( ".hubcode_list" ).autocomplete({
source: hubcode_list
});