From 69aa1c4b335136c1028bec5a9b83f17eeb8b0b8d Mon Sep 17 00:00:00 2001 From: LV-426 Date: Wed, 4 Feb 2015 03:05:19 +0200 Subject: login.html: refactor code into user_login.js --- src/client/user_login.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/client/user_login.js (limited to 'src') diff --git a/src/client/user_login.js b/src/client/user_login.js new file mode 100644 index 00000000..3e304b64 --- /dev/null +++ b/src/client/user_login.js @@ -0,0 +1,26 @@ +"use strict" + +function submit_login_form() { + var data = { + username : $('#login_username').val(), + password : $('#login_password').val() + }; + + // TODO: validate + + $.ajax({ + type : "POST", + url: '/login', + async : false, + cache : false, + data : JSON.stringify(data), + dataType : 'json', + contentType : "application/json; charset=utf-8", + success : function () { + document.location = "/index"; + }, + error : function (xhr, status, err_thrown) { + $('#failed-login').show(); + } + }); +} -- cgit v1.3.1