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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:57:29+00:00 2026-05-27T12:57:29+00:00

I am currently working on an MVC application where I use a lot of

  • 0

I am currently working on an MVC application where I use a lot of jQuery and html forms. However, recently I have noticed that these seem to contradict each other somewhat…

For example, I have to prevent the forms default submit to process my AJAX call, otherwise the server gets called twice which leads me to question the idea of using AJAX to submit the form. Wouldn’t it be better instead to just hook the $.ajax call to an <input type="button" /> than an <input type="submit" />?

So, is it contradictory to have a form that is submitted through ajax?

  • 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-27T12:57:30+00:00Added an answer on May 27, 2026 at 12:57 pm

    The reason you would put the ajax call on a submit button is so there is a natural fallback if the user has javascript disabled. You should have your backend logic detect if the request is an ajax request or just a straight up submit and be able to either send the data back if it’s ajax or process the request the ‘old school’ way if not.

    Edit: For context.

    <form action="/processForm.php" method="POST">
       <input type="submit" value="submit" />
    </form>
    

    Then your jQuery could look like this

    $('form').bind('submit', function(e){
        e.preventDefault();
        //do your stuff
    });
    

    If the user has disabled javascript, the form will just submit to /processForm.php like normal.

    You can detect if the form was sent via ajax or not with the following php (I don’t know if that’s what you’re using, but it’s what I’ve got).

    if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
      /* handle ajax here */
    }else{
      /* handle normal submit here */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a web application using Spring MVC, and I use the
I'm working on an asp.net MVC application. I have a class that wraps a
I'm currently working on an Asp.net MVC Web application. In my solution, there're two
I have a MVC 4 project I am currently working on and need some
First some background, I am currently working on a relatively large Asp.Net MVC application
I am currently working on a ASP .Net MVC 3 application to do some
Currently I am working on small application in asp.net mvc. It is a some
I've currently got an app that me and a few mates have be working
I have correctly implemented authentication on an MVC application I have been working on
I am currently working on my first asp.net mvc application. I am trying to

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.