This is the simple HTML page with a text box and a search button
<!DOCTYPE html>
<html>
<body>
<input type="text" name="queryString"><br>
<button type="button" name="searchButton">Search</button>
</body>
</html>
Initially, the above HTML page is served by a bottle server (I am going to omit the code), and then I wish to process the search queryString using:
@route('/', method = 'GET')
def processSearch():
queryString = request.forms.get("queryString")
print 'queryString is:', keyword
return 'processSearch() executed'
My question is: without a Javascript onclick listener function (which would make an AJAX call), is it possible to click on the search button and fire a GET request which starts executing processSearch()?
Note: I am aware POST is ideal for form data submission, but I am still interested to know if this will work.
Put it in a form, and change the button to a submit
input:
<form action="yourscript.py" method="get">
<input type="text" name="queryString"><br>
<input type="submit" name="searchButton" value="Search">
</form>