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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:58:35+00:00 2026-05-27T15:58:35+00:00

I have a form with the following button: <input id=test2 class=formbutton type=submit value=Play again

  • 0

I have a form with the following button:

<input id="test2" class="formbutton" type="submit" value="Play again" />

Pressing the submit fires this javascript:

$("#test2").click(function(){
        $.ajax({   
            type: "POST",
            data: $("#form").serialize(), 
            cache: false,  
            url: "insert.php"  
        });   
        return false;
    });

This all works fine. The problem is when I try to ad location.href="mahjong.php?layout=win"; What I want is that when I press this button, the form is submitted and loads the url mahjong.php?layout=win

If I use:

$("#test2").click(function(){
location.href="mahjong.php?layout=win";
$.ajax({   
            type: "POST",
            data: $("#form").serialize(), 
            cache: false,  
            url: "insert.php"  
        });   
        return false;
    });

I go to the url but the form is not always submitted. How to fix this. I cannot edit the insert.php file since this one is used by other buttons too (where no redirection is needed)

  • 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-27T15:58:35+00:00Added an answer on May 27, 2026 at 3:58 pm

    Go to the link after the form has returned, using a success handler:

    $("#test2").click(function () {
        $.ajax({
            type: "POST",
            data: $("#form").serialize(),
            cache: false,
            url: "insert.php",
            success: function () {
                location.href = "mahjong.php?layout=win";
            }
        });
        return false;
    });
    

    It’s probably worth putting some visual notification on the page, e.g. a spinner or disabling the button, so that the user knows something is happening and doesn’t click the button again.

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

Sidebar

Related Questions

I have the following form: <input name=q value= class=qa-search-field> <input type=submit value=Search class=qa-search-button> I
I have the following submit button: <input type=submit name=submit value=Send class=mybutton /> When I
I have a form with <input type=button name=submit /> button and would like to
I have the following html button <td><form id=form2 name=form2 method=post onclick=../cgi-bin/py/GuestBookEntry.py> <input type=submit name=gBookSrib
I have a button element inside a form like this: <form> <input type=text> <button>Test</button>
Assume we have a single Windows form with a button called SimpleButton1. The following
I have the following form code: # forms.py class SomeForm(forms.Form): hello = forms.CharField(max_length=40) world
I'm looking at some Java classes that have the following form: public abstract class
I have the following Radio Buttons: <form id=bg action=#> <span id=questionText>Question Test Here:</span><br/> <input
I have the following form. <h1>Please Confirm Your Order</h1> <p class=padnmgn>Please confirm your order

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.