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 1061137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:26:00+00:00 2026-05-16T18:26:00+00:00

I am trying to make condition to call chain function in Jquery. I used

  • 0

I am trying to make condition to call chain function in Jquery. I used $.ajax in Jquery submit function to get values from login.php and I am trying to call fadeOut function to close login form. If login succes form will close then there will be some Success message and then it wil lalso close. And if error then form will remain and also error message.
I made it also but in my login.js when I call $(‘.loginform’).fadeOut(1000) it works also if login succes or not.

jQuery('#login').live('submit',function(event) {

$.ajax({
    url: 'lib/login.php',
    type: 'POST',
    dataType: 'json',
    data: $('#login').serialize(),
    success: function( data ) {

       for(var id in data) {
            jQuery('.' + id).html(data[id]);    
        }
$('.loginform').hide(1000);     

    }
 });

return false;
 }

});

and my login.php file includes

if(result==1){
  $arr = array ( "loginOK" => "Success." ); 

} else {

 $arr = array ( "errors" => "Please try again ." );

}
echo json_encode( $arr );

this is index.html

    <!--Login Form tag -->

<div class='errors'></div>

 <div class='loginOK'></div>

<div class='loginform'>

  <form  action ="" method="post" id="login">
    <fieldset class="loginfield">
        <legend>Login</legend>
        <div>
            <label for="username">User Name</label> <input type="text" id="username" name="username">
        </div>
        <div>
            <label for="password">Password</label> <input type="password" id="password" name="password">
        </div>
    </fieldset>
      <button type="submit" id="submit-go" ></button>
<a href="#?w=500" rel="popup_name" class="poplight">Sing up</a>

</form>

</div>
  • 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-16T18:26:00+00:00Added an answer on May 16, 2026 at 6:26 pm

    the success: function( data ) { handler executes when the request is successful, not when the login is successful. You need to provide a flag in your json to indicate that, and check that flag it in your handler:

    success: function( data ) {
    
        if(data.success) {
           for(var id in data) {
               jQuery('.' + id).html(data[id]);    
           }
           $('.loginform').hide(1000);   
    
        }  else {
           alert('Error logging in');
        }
    
    }
    

    EDIT:

    Your current json object is like

    {
      id_1:'html_1',
      id_2:'html_2'
    }
    

    You should make it something like

    {
      html: {
        id_1: 'html_1',
        id_2: 'html_2'
      },
      success: $login_success
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.