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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:09:44+00:00 2026-06-02T05:09:44+00:00

I use MVC and would like to submit a form via jquery, but for

  • 0

I use MVC and would like to submit a form via jquery, but for the mvc built in validation to work in case of a any invalid input, I’ve conditioned the “return false” of the click event (also tried “event.preventDefault”), in case of getting a “success” json return from the controller.

Here’s the code:

$(document).ready(function () {
    var request;
    $('#formSubmit').click(function (event) {
        request = $.ajax({
            url: '/personManager/loadDetails/',
            type: 'post',
            data: $('form').serialize()
        });
        request.done(function(data){
            if(data=="success")
                event.preventDefault();
            });

        });
    });

I can’t make it work…
What do I do wrong?
also, is there any more efficient way to preserve mvc validation mechanism, while working with jquery?

updated: If I try to describe my wish more simply: I want to condition the preventDefault of the click event, so in a certain condition it will invoke the form submit, and in other, it won’t, and only $.ajax work.
The second accures after I confirm on the server side that no action has taken place.
There’s must be a way, I guess…

  • 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-02T05:09:45+00:00Added an answer on June 2, 2026 at 5:09 am

    The problem is most likely because your ajax is asynchronous. Set it to be synchronous and your code should work fine. However be aware that if the server fails to respond instantaneously you risk your user’s browser freezing up.

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

Sidebar

Related Questions

I would really like use the jQuery Validation plugin in my ASP.NET Web Forms
For class, I would like a to use PHP MVC framework very similar to
Starting a new project and would like to use one of the MVC framworks.
I'm using ASP.NET MVC Preview 4 and would like to know how to use
I've just come across these in MVC, and would like to use them instead
Under what circumstances would you use MicrosoftAjax over jQuery in an ASP.NET MVC application?
I'm using ASP.NET MVC and would like to get Model information for use within
Using win forms with an MVC / MVP architecture, I would normally use a
I use Spring MVC [version: 2.5] and Security[version: 2.0.4]. My problem looks like that:
I've created a few html helper methods for asp.net mvc that I would like

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.