/** * Activates ajax submit buttons. */ function authenticate() { /** * Login */ $("#login").submit(function(e) { $.ajax({ type: "POST", cache: false, dataType: "json", url: "/tippspiel/login", data: $(this).serializeArray(), success: function(data) { if (data.success) { location.replace("/tippspiel/overview"); } else { error(data); if (data.msg) { msg(data.msg); } } } }); return false; }); /** * Signup */ $('').attr({ type: 'hidden', name: 'csrf', value: csrf }).appendTo('#signup'); $("#signup").submit(function(e) { $.ajax({ type: "POST", cache: false, dataType: "json", url: "/tippspiel/signup", data: $(this).serializeArray(), success: function(data) { if (data.success) { $.fancybox.close(); } else { error(data); } msg(data.msg); } }); return false; }); /** * Forgot password */ $('').attr({ type: 'hidden', name: 'csrf', value: csrf }).appendTo('#forgot-password'); $("#forgot-password").submit(function(e) { $.ajax({ type: "POST", cache: false, dataType: "json", url: "/tippspiel/forgot-password", data: $(this).serializeArray(), success: function(data) { if (data.success) { $.fancybox.close(); } else { error(data); } msg(data.msg); } }); return false; }); }