Jinja gets rendered on the server so you can't mix and match it with javascript. Try something like this:
var counts = {{ test|tojson }},
// before the HTML file gets to the browser this line will be:
// baseURL = "/ques/REPLACE"
baseURL = "{{ url_for('ques', idd='REPLACE') }}";
for (i = 1; i < counts.length; i = i+2) {
var url = baseURL.replace('REPLACE', counts[i-1]);
document.write("" +
counts[i] + "");
}
Otherwise you'll need to build the URL directly in Javascript.
A better way of doing it would be to use request arguments:
@app.route('/ques/')
def ques():
# url is: /ques/?idd=ABC
idd = request.args.get('idd', default='', type=str)
print idd
Javascript:
var counts = {{ test|tojson }},
baseURL = "{{ url_for('ques') }}";
for (i = 1; i < counts.length; i = i+2) {
var url = baseURL + '?idd=' + counts[i-1];
document.write("" +
counts[i] + "");
}