Don't close modal on failure, redirect on success

This commit is contained in:
Phillip Kühne 2019-05-22 03:17:32 +02:00
parent ab1db95d06
commit 1fc2511cbf
3 changed files with 9 additions and 4 deletions

View File

@ -16,7 +16,7 @@ def enqueue():
name = request.json['name']
song_id = request.json['id']
database.add_entry(name,song_id)
return "OK"
return Response('{"status":"OK"}', mimetype='text/json')
@app.route("/list")
def songlist():

View File

@ -23,4 +23,5 @@
</tr>
{% endfor %}
</table>
<a name="end"></a>
{% endblock %}

View File

@ -74,7 +74,7 @@
});
function enqueue(id,name) {
function enqueue(id,name,success_callback) {
var data = {
"name": name,
"id": id
@ -83,6 +83,7 @@
type: 'POST',
url: '/api/enqueue',
data: JSON.stringify(data), // or JSON.stringify ({name: 'jonas'}),
success: success_callback,
contentType: "application/json",
dataType: 'json'
});
@ -95,8 +96,11 @@
function submitModal() {
var name = $("#singerNameInput").val();
var id = $("#selectedId").attr("value");
enqueue(id,name);
$("#enqueueModal").modal('hide');
enqueue(id,name,function(){
$("#enqueueModal").modal('hide');
window.location.href = '/#end';
});
}
</script>