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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:42:46+00:00 2026-05-17T23:42:46+00:00

I am writing a form to be inserted in clients’ webpages that is to

  • 0

I am writing a form to be inserted in clients’ webpages that is to be submitted with an AJAX request for processing. Then, depending on the client’s settings, I want to either display a “Form Successfully Submitted” victory message, or I want to redirect the user to my site (by submitting the form to my site) for additional processing.

I’m using jQuery to try to get this to work. My strategy is to put a “live” binding to the submit event on my form, which then prevents the default submission and does a jQuery post using the form values as parameters for processing at my site. If the form passes validation AND its determined that the user needs to be redirected, the form submission is triggered again, but this time the submit handler returns true, which should enable the default, right? It does return true (I checked with alerts), but the form is not submitted. Here is sample code:

<form id="myform">
    <!-- Elements in here -->
    <input type="submit" value="Submit" name="submit" id="submit">
</form>
<script>
    var handleSubmit = true;
    $("#myform").live('submit', function(){
        if (handleSubmit === true){
            $.post('http://example.org', $('#myform').serialize(), function(response){
                if (response.success){
                    if (response.redirect){
                        handleSubmit = false;
                        $('#myform').attr('action',response.redirect);
                        $('#myform').submit();
                    } else {
                        alert('success!');
                    }
                } else {
                    // replace form contents with response.html (the form w/ errors)
                }
            }, 'json');
            return false;
        } else {
            // submit form (default action)
            return true;
        }
    });
</script>

I’ve tried different things like putting the submit trigger within a setTimeout, or using ‘bind’ instead of using live, but the result is the same.

One thing that is perhaps important to note is that the above code and the code for the form itself is also generated from an AJAX request from the client’s site.

Any guidance you could give would be much appreciated. I am also definitely open to different ways of doing this.

Thanks!

  • 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-17T23:42:47+00:00Added an answer on May 17, 2026 at 11:42 pm

    The problem that you’re having is actually with the input element:

    <input type="submit" value="Submit" name="submit" id="submit">

    The redirecting form submit is failing because names of form controls within a form element are exposed as properties of the form in the DOM and can cause conflicts with the form‘s original properties. Conflicts like this will fail silently when triggering events through jQuery’s event functions. Changing your input element to the following should fix the problem you’re having:

    <input type="submit" value="Submit">

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

Sidebar

Related Questions

I'm writing a form in XAML that has multiple buttons with content of different
I'm currently writing some methods that do some basic operations on form controls eg
I'm writing a form that has some text input elements loaded dynamically when a
It's so clumsy to always be writing Request.Form[blah]... is there any sort of way
I am writing an HTML form that uses a google map, but to reduce
I'm writing a form that has several mutually exclusive options, but none of them
I'm using Vim to write text that isn't code, just free form writing. To
I'm writing a search form for my Rails (2.3.9 but I've checked that this
I am writing a C# form based application that stores its data in SQL
I am writing a form validator that needs to combine the values of three

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.