diff --git a/main.py b/main.py index 0dacf11..fa3f7b8 100644 --- a/main.py +++ b/main.py @@ -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(): diff --git a/templates/main.html b/templates/main.html index a0cbdb0..880cdb4 100644 --- a/templates/main.html +++ b/templates/main.html @@ -23,4 +23,5 @@ {% endfor %} + {% endblock %} \ No newline at end of file diff --git a/templates/songlist.html b/templates/songlist.html index 7e09e61..870e38d 100644 --- a/templates/songlist.html +++ b/templates/songlist.html @@ -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'; + }); + }