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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:19:08+00:00 2026-05-29T19:19:08+00:00

I’m making a form submit with jQuery’s AJAX. I’m having several form’s using AJAX

  • 0

I’m making a form submit with jQuery’s AJAX. I’m having several form’s using AJAX like this:

$('#newUser').submit(function() {
var dataString = $(this).serialize();

$.ajax({  
    type: "POST",  
    url: "/includes/classes/handler.php?do=addLogin",
    data: dataString,
    success: function(returnedData){

        if(returnedData){
            $('.errorMessage').fadeIn().html(returnedData);
        } else {
            $('.sideBarNewUserWrap').fadeOut();
        }

    }
});
return false;
});
//

and then I am having another one like this:

$('#addLookup').submit(function() {
var dataString = $(this).serialize();

$.ajax({  
    type: "POST",  
    url: "/includes/classes/handler.php?do=addLookup",
    data: dataString,
    success: function(returnedData){

        if(returnedData){
            $('.errorMessage').fadeIn().html(returnedData);
        } else {
            window.location.href = "";
        }

    }
});
return false;
});

And for some reason, when I wan’t it to trigger the #newUser it’s triggering the #addLookup. If I remove the #addLookup, there’s no AJAX OR jQuery running for #newUser (the browser is just refreshing if I click on “submit”).

The forms look like this:

<form method='post' action='#' id='newUser'></form>

or

<form method='post' action='#' id='addLookup'></form>

How can this be? I’ve been looking at the same code for 2 hours now, and I can’t figure out what’s wrong.

Update

The #addLookup is only triggered if the 2 forms are on the same page. If the #newUser is standing alone on a page AJAX’s triggering the right function.

The full HTML

<form method='post' action='#' id='addLookup'>

    <div id='tilfojOpslagClose'><img src='/includes/images/design/btn/closeWindow-btn.png'></div>

    <div class='successMessage'></div>
    <div class='errorMessage'></div>


    <div id='tilfojOpslagHeader'>
        <input type='text' name='lookupHeader' id='lookupHeader' value='Skriv en overskrift'>
    </div>

    <div id='tilfojOpslagExpand'>

        <div style='float:left;'>
            <label>Præsentations tekst (bliver vist på forsiden)</label> 
                <textarea name='lookupSubHeader' id='lookupSubHeader' maxlength='100'></textarea>
        </div>
            <span id='lookupSubHeaderCharsLeftOutput'>Du mangler <strong>50</strong> tegn</span>

        <div style='float:left;width:618px;margin:3px 0 0 0;'>
            <textarea name='lookupContent' id='lookupContent' style='height:100px;'></textarea>
        </div>

        <div id='tilfojOpslagBottom'>
            <div id='tilfojOpslagSubmit'><input type='submit' value='Opret mit opslag'></div>
        </div>
</form>

And for #newUser

<form method='post' action='#' id='newUser'>
        <fieldset>
            <legend>Ny bruger</legend> 
                <label>Brugernavn</label>
                    <input type='text' name='username' id='username' placeholder='Brugernavn vil forekomme på siden, som et alias'>
                <label>E-mail</label>
                <label style='color:#f00;font-size:8px;'>Ja, du skal skrive en gyldig e-mail. Du modtager et aktiverings link.</label>
                    <input type='text' name='email' id='email' placeholder='E-mail - en del af dit login'>
                <label>Adgangskode</label>
                    <input type='password' name='password' id='password' placeholder='Adgangskode - en del af dit login'>
                <input type='hidden' name='salt' id='salt' value='<?=uniqid(mt_rand())?>'>
                <input type='submit' value='Opret mig'>

                <div class='errorMessage'></div>
                <div class='successMessage'></div>
        </fieldset>
        </form>

UPDATE

<?if($_SESSION['loggedIn']){?>
    <form action='' method='' id='addLookup'>
<?} else {?>
    <input type='submit' value='something'>
    </form>
<?}?>
  • 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-29T19:19:09+00:00Added an answer on May 29, 2026 at 7:19 pm

    The problem comes in from the SUBMIT button behaviour. A specific submit inside a form will only post the form that contains it. I compiled a quick jsFiddle that illustrates it. If you trigger a submit button that’s not contained in a form, neither of the forms will post. If you trigger a specific submit button that’s inside a specific form, only THAT form will be posted.

    Al alternative might be to manually post both forms by attaching an OnClick event handler to the submit buttons…

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I am reading a book about Javascript and jQuery and using one of the
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string

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.