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

  • Home
  • SEARCH
  • 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 9190287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:25:38+00:00 2026-06-17T20:25:38+00:00

Currently my form is being submitted through ASP.NET as well as through AJAX, but

  • 0

Currently my form is being submitted through ASP.NET as well as through AJAX, but I only want it submitted through AJAX (and i don’t want to use Ajax.BeginForm because it’s smelly).

Please note I stripped data from the form down to just the elements involved, more or less.

    @using (Html.BeginForm("Action", "Controller", FormMethod.Post))
    {
    <div style="width:275px;">
        <a href="#" id="edit_licenses" class="grayBtn left">Edit</a>
        <a href="#" id="cancel_licenses" style="display:none;" class="grayBtn left">Cancel</a>
        <input id="submit_licenses" type="submit" style="display:none;" value="Save" class="redBtn right" />
    </div>
    }
    <br />
</div>

<script type="text/javascript">
    $('#edit_licenses').click(function () {
        swap_licenses(false);
        return false;
    });

    $('#cancel_licenses').click(function () {
        swap_licenses(true);
        $('form').resetForm();
        return false;
    });

    $('form').submit(function (e) {
        if ($(this).valid()) {
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result) {

                }
            });
        }
        return false;
    });

    var swap_licenses = function (bool) {
        $('.licenses').each(function () { $(this).attr('disabled', bool); });
        $('#submit_licenses, #edit_licenses, #cancel_licenses').toggle();
    }
</script>
  • 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-17T20:25:40+00:00Added an answer on June 17, 2026 at 8:25 pm

    Did you try using the preventDefault method to prevent the normal form submit ?

    $(function(){ 
    
       $('#submit_licenses').click(function (e) {
            e.preventDefault();
            var _this=$(this);
            swap_licenses(false);           
            PostForm(_this.closest("form"));
       });
    
    });
    
    function PostForm(postedForm)
    {
       //postedForm will be the form object here. You may do your validation here
    
         $.ajax({
                  url: postedForm.attr("action"),
                  type: postedForm.attr("method"),
                  data: postedForm.serialize(),
                  success: function (result) {               
                }
          });
     }
    
    function swap_licenses(someParameter)
    {
       //This method does something useful
    }
    

    Now you do not need to the event handler for form submit event as we already bounded that to the submit button.

    Also form submitting/posting should be always a HTTP Post method. So you can simplify your PostForm method like this

    function PostForm(postedForm)
    {
        $.post(postedForm.attr("action"),postedForm.serialize(),function(data){
           //do something with the response
        });          
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a PHP form that uses AJAX to connect to MySQL and
I am currently working on an ASP.net c# project. I have an aspx page
Using Visual Studio 2010, MVC project When my form is submitted (currently via javascript,
I'm working with ReCaptcha, ASP.NET and Gaia Ajax . It took me some time
When a form is being submitted, I need to check if a duplicate already
I have an HTML form, being submitted to a PHP page. The PHP page
I'm developing this app which as a very basic Ajax form and I'm currently
I am trying to add validation to a form that is submitted by ajax,
I have a timesheet in a browser-compatible InfoPath 2010 form, which is being submitted
I currently have form that checks if a user has unsubmitted changes when they

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.