I'm using Flask to build a D3 visualization and am requesting user data from a form using JQuery and D3.
$('form').submit(function(e) {
e.preventDefault();
d3.json("{{ url_for('crew') }}")
.header('Content-Type', 'application/x-www-form-urlencoded')
.post($(this).serialize(), function(error, graph) {
When the user chooses data and presses Submit, a graph shows. The problem is that when Submit is pressed again, another graph appears on top of the old one. I need to refresh before resubmitting the form.
@app.route('/crew', methods=['GET', 'POST'])
def crew():
form = CrewForm()
if form.validate_on_submit():
return current_app.send_static_file(os.path.join('crews/', form.filename.data))
return render_template('Crew.html', form=form)