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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:57:32+00:00 2026-06-11T07:57:32+00:00

Consider the following scenario: I have a page that can open a dialog (jquery

  • 0

Consider the following scenario: I have a page that can open a dialog (jquery dialog). This dialog allow the user to update some values or even insert new ones. The user, sometimes, clicks several times on the “Confirm” button, which fires the update or insert as much as the times clicked. The method is fired through an ajax call (jquery ajax), that on success show the user a nice “It’s done” message.

On the update scenario, it’s fine, even though my server code has to call the update command on database as much times as the method is called. However on the insert situation, my data is submitted several times and several rows are inserted on database. This causes a lot of problems on other areas.

I read about the post-redirect-get pattern which would the ideal solution for my problem. But it only says about a non ajax post. What about when the call to the method is done through an ajax call? How to prevent an user from submitting several times the same thing?

I tried to block the button on the dialog and even though it works, i think is bad solution, since the button may not be blocked all times, specially if the user has some problem on his browser.

  • 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-11T07:57:33+00:00Added an answer on June 11, 2026 at 7:57 am

    Even though Nathan Taylor’s solution was possible and correct, i prefered to do something more simple. I created a local boolean that should check if the form was submitted or not. The first time the form is submitted this variable receives true and prevents further submissions. Check the code below:

    <script type="javascript">
    var isSubmit = false;
    
    $('#myForm').submit(function(){
      //Check if this is the first time the form is submitted
      if(isSubmit === true){
      return false;
    }
    isSubmit = true;
    //Executes the form submission as it should be
    });
    </script>
    

    Remember to create this isSubmit var on the dialog scope, otherwise you won’t be able to submit this form anymore, unless, of course, you change the variable somewhere else.

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

Sidebar

Related Questions

Consider following scenario: I have RESTful URL /articles that returns list of articles user
Consider the following scenario We have a simple database that involves two entities: user
Let's consider the following scenario. I have the following page where all rendered elements
Consider the following scenario: http://www.restserver.com/example.php returns some content that I want to work with
This might be a novice question. :). Consider the following scenario. Suppose we have
consider following scenario input string = WIPR.NS i have to replace this with WIPR2.NS
please consider the following scenario for .net 2.0: I have an event that is
Consider the following scenario . I have an array of numbers: [ 1,2,3,4 ]
From couple of days i am thinking of a following scenario Consider I have
I have a question regarding a race condition scenario. The question: Consider the following

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.