Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6129697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:46:23+00:00 2026-05-23T16:46:23+00:00

I have a login form inside a fancybox that does its thing via ajax.

  • 0

I have a login form inside a fancybox that does its thing via ajax. I need that when the login is successful the page will reload, but not if the login fails. I used to have

'onClosed': function() {   parent.location.reload(true); }

on my fancybox but that would reload the thing even if the user just manually closed the fancybox without logging in.

I have this function for loging:

$("#loginform").bind("submit", function() {
        if ($("#username").val().length < 1 || $("#password").val().length < 1) {
            $("#login_error").show();
            $.fancybox.resize();
            return false;
        }

        $.fancybox.showActivity();

        $.ajax({
            type        : "POST",
            cache       : false,
            url         : "/login/ajax-login.php",
            data        : $(this).serializeArray(),
            success: function(data) {

                switch(data){
                    case "1"://exito
                        function() {window.location.reload(true);}
                        //THIS DOESN'T WORK
                    break;
                    case "0"://error
                        $.fancybox("ERROR. El usuario no existe o es incorrecto.");
                    break;
                }
            }
        });

        return false;
    });                       

As you can see, when data equals 1 the login is succesful but nothing will happen. If I manually reload the page I see the login was successful tho.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:46:23+00:00Added an answer on May 23, 2026 at 4:46 pm

    A switch statement does not accept callbacks. Your code appears as if you thought they did.

    You need to run that function…

    function() {window.location.reload(true);}
    

    …at the moment you have just defined an anonymous function which has not been assigned to any variable.

    Easiest way is to drop the wrapper function…

    window.location.reload(true);
    

    …or if you insist of having a function (why?) you could use…

    (function() {window.location.reload(true);})();
    

    Most people use the former for information hiding, but you declare no new variables, so it’d be pointless.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login form that has Username and password as inputs from user
There are some HTML based games (ie bootleggers.us) that have a simple login form
I have this situation: There are a login page with a login form (form
i have a website that has a simple login form. the form posts to
I have this login form on my program in C#, I will be matching
Please help. I have page login/auth.gsp with the following code inside the body <div
I have to login to a page using three parameters, after that I have
We have a custom list inside a moss publishing site that an asp.net form
I have a page in a site that contains an iframe with a form
I have this very simple login form with user and pass and I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.