My goal is for the user to fill out the form, send this information in a POST request to the flash server, and then visualize the template using this form information (after it has some logic on the server).
So far, I have completed the POST part of all of this. I am trying to make a template right now in if request.method == POST' , and I think it is not working right now.
Here is the code that I still have:
@app.route('/filteredsearch/', methods = ["GET", "POST"]) def filteredsearch(): if request.method == 'POST': data = json.loads(request.data) tables = data['checkboxes'] filter_results = getFilteredEntities(tables = tables) print filter_results #This works return render_template("filteredsearch.html", entities = filter_results)
Should I make a separate GET request about the success of my POST function? If so, how do I do this?
Here is an AJAX request (if that matters, this code can be called on every page of the application):
$.ajax({ url:"/filteredsearch/", type: 'POST', data: json, contentType: 'application/json;charset=UTF-8', success: function() { alert("Done"); } });
So, ideally, I can display the template at the time of publication. If this is not the case, how do I make a GET request from the same ajax function?
I know that, as a rule, you use url_for() to request a GET , is this parameter given that I am in JS at this point?
jquery python ajax flask
Alex Chumbley
source share