I have def function, which return a query result as array and return jsonify, but it is returning empty
The def is
@app.route('/newsearchresults')
def newsearchresults():
name = request.args.get('query')
customers = {}
customers = Customer.query.filter(Customer.name.like('%'+str(name)+'%')).all()
return jsonify(customers)
the HTML form is this, which calls the jquery functions
<form action="/newsearchresults" >
<Text text="Customer Name" id="text0"/>
<Input width="200px" name="custName" required placeholder="Please enter the customer name"/>
<button type="submit">Search Customer</button>
</form>
and the jquery script on Html file is
$( document ).ready(function() {
$('form').on('submit', function()
{
name =$("input[name='custName']").val()
$.get("/newsearchresults", {'query': name}).done(function (data)
{
});
I want to populate the jsonify response result to this table below in the same html file
<table border="1" >
<tr><td><strong>Customer Id</strong></td><td><strong>Name</strong></td><td><strong>E Mail</strong></td> <td><strong>Mobile No</strong></td></tr>
{% for name1 in customers %}
<td><a class="customername" href="#" data-name="{{ name1.name }}">{{name1.id}}</a></td><td>{{name1.name}}</td><td>{{name1.email}}</td><td>{{name1.mobileno}}</td></tr>
{% endfor %}
</table>