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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:19:24+00:00 2026-06-09T06:19:24+00:00

I have a login form with a username and password. I make a post

  • 0

I have a login form with a username and password.
I make a post to a web service with the user and pass as parameters and I get back an ID for that user.

What I am trying to achieve is that on form submit, the ajax call is made which in turn populates the ID field (which I need) and then submits the form using $('#form1').post();.

To prevent default behavior, I have a return false; at the beginning of the .submit() event.

$('#form1').submit(function() {         
        $('#sajax-loader').show();        
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            data: '{user:"' + $("#user").val() + '",pass:"' + $("#pass").val() + '"}',
            url: "URL.asmx/validate",
            dataType: "json",
            success: function (data) {
                $('#id').val(data.d);                
                $('#sajax-loader').hide();                                             
                $('#form1').post();
                $('#login-notification').show();                                
            },
            error: function (err) {
                $('#login-notification').html("An Error Occured " + err);
            }
        });
        return false; 
    });

Obviously this is the wrong approach since I am not getting any response when submitting.

Can anybody guide me in the right direction? Give some advice on how to tweak this submit function I have here, or maybe an entirely different more practical approach?

  • 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-06-09T06:19:27+00:00Added an answer on June 9, 2026 at 6:19 am

    Beginning return false will stop the execution of submit() function at that point from where you return and rest of the code is not executing. So, place your return false at the end.

    In other way, using .preventDefault() will stop default form submission behavior.

    $('#form1').submit(function(e) { 
    
            // instead of return false
            // use e.preventDefault()           
    
            e.preventDefault();
            $('#sajax-loader').show();        
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                data: '{user:"' + $("#user").val() + '",pass:"' + $("#pass").val() + '"}',
                url: "URL.asmx/validate",
                dataType: "json",
                success: function (data) {
                    $('#id').val(data.d);                
                    $('#sajax-loader').hide();                                             
                    $('#form1').post();
                    $('#login-notification').show();                                
                },
                error: function (err) {
                    $('#login-notification').html("An Error Occured " + err);
                }
            });
        });
    

    And one thing

    Instead of

    data: '{user:"' + $("#user").val() + '",pass:"' + $("#pass").val() + '"}',

    you can use:

    data: {user: $("#user").val() ,pass: $("#pass").val() },

    • 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
Suppose I have the file login.php . login.php takes get (or post) parameters username
I've been trying to make a web service that receives a username and password
I have a small web app that uses a simple username/password login scheme. I've
I have a login screen with username and password credentials that are validated throught
I have been trying to make a user login page that, when the user
I have WPF application that has a login form. I would like to make
I make a login form with dynamic field validation. I have 3 fields username,
on my web site I want to have login/registration form in modal window done
I would like to have a simple login form (or any form for that

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.