0

I have changed nothing in the pset8 distribution code and only implemented search function and formatted configure in script.js, but no suggestion shows up from the search box 'q'.

This worked perfectly a few weeks ago but now Chrome shows the error:

Uncaught ReferenceError: Flask is not defined

that points to this line in script.js

$.getJSON(Flask.url_for("search"), parameters)

The following is my search function, which worked a few weeks ago:

@app.route("/search")
    def search():
    """Search for places that match query"""

    '''find places that match the value of q in postal_code or place_name'''
    q = request.args.get("q") + "%"

    '''return JSON object of up to 10 places'''
    places_list = db.execute("SELECT * FROM places WHERE postal_code LIKE :q OR place_name LIKE :q OR admin_name1 LIKE :q OR admin_code1 LIKE :q OR admin_code2 LIKE :q", q=q)
    return jsonify(places_list[:10])
1

I'd change that to simply $.getJSON("/search", ....) with no reference to Flask.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .