Hej!
Jeg har problemer med en try/catch syntaks. Alt virker, bortset fra den exception, som er pakket ind i ajax-kaldet (linje 33). Hvorfor kan jeg ikke få den til at poppe op?
- try
- {
- if($("#signinusername").val() == "" && $("#signinpassword").val() == "") throw "Please enter a username and password.";
- else if($("#signinusername").val() == "" && $("#signinpassword").val() != "") throw "Please enter a username.";
- else if($("#signinusername").val() != "" && $("#signinpassword").val() == "") throw "Please enter a password.";
- else
- {
- // check username and password with ajax
- var usr = $("#signinusername").val();
- var psw = $("#signinpassword").val();
- var ckie = $("#signincookie:checked").val();
- $.ajax(
- {
- url: signinpage,
- type: 'POST',
- data: {
- action: "signin",
- username: usr,
- password: psw,
- cookie: ckie
- },
- success: function(data)
- {
- if(data == 1)
- {
- $("#signinstatus")
- .removeClass("error")
- .addClass("success")
- .html("Signin OK. Redirecting...")
- .slideDown('slow', 'easeInQuad');
- setTimeout("location.href='"+redirect+"'", 3000);
- }
- else throw "Password and username does not match.";
- }
- });
- }
- }
- catch(err)
- {
- $("#signinstatus")
- .removeClass("success")
- .addClass("error")
- .html(err)
- .slideDown('slow', 'easeInQuad')
- .delay(3000)
- .slideUp('slow', 'easeOutQuad');
- }
Indlæg senest redigeret d. 25.04.2013 16:25 af Bruger #16927