$("#signin_anon").click(function (event) { event.preventDefault(); // hide alerts $("#alertMSG").addClass("hidden"); // try to login $.ajax({ type: "POST", url: "/api/captiveportal/access/logon/" + zoneid + "/", dataType:"json", data:{ user: '', password: '' } }).done(function(data) { // redirect on successful login if (data['clientState'] == 'AUTHORIZED') { if (getURLparams()['redirurl'] != undefined) { window.location = 'http://'+getURLparams()['redirurl']+'?refresh'; } else { window.location.reload(); } } else { $("#inputUsername").val(""); $("#inputPassword").val(""); $("#errorMSGtext").html("login failed"); $("#alertMSG").removeClass("hidden"); } }).fail(function(){ $("#errorMSGtext").html("unable to connect to authentication server"); $("#alertMSG").removeClass("hidden"); }); });