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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:15:21+00:00 2026-05-29T20:15:21+00:00

I use the jQuery ajax function to send data to 2 php scripts. The

  • 0

I use the jQuery ajax function to send data to 2 php scripts. The first script inserts the received data into a MySQL db, the second sends emails. The ajax functions are attached to a click event. For some unknown reason sometimes there are 2 or 3 database entries and sent emails even if I click only once. As you can see the 2nd ajax call is embedded into the first one. I tried to use them in parallel. Tried without ‘set timeout’-s. I also use here the simplemodal plugin. When the first modal closes, the second opens.

Is there a way to make sure that the click event is triggered only once or to block the ajax requests after 1 successfull call?

Here is a part of the code:

$('#confirm').click(function () {

    $('#loading').html("<img style = 'display:inline-block;' src = 'img/loading.gif' />");
    var servtype = $('select option:selected').text();

    $('#type').text(servtype);
    $('#staff_name').text(staff_name);
    $('#day_time').text(a);
    $('#day_date').text(nap + ', ' + dateText);
    $('#type1').text(servtype);
    $('#staff_name1').text(staff_name);
    $('#day_time1').text(a);
    $('#day_date1').text(nap + ', ' + dateText);
    var message = $('#message').val();

    $.ajax({
        type: 'GET',
        async: true,
        url: 'add_booking.php',
        data: 'message=' + message + '&date=' + dateText + '&start_end=' + a + '&personid=' + personid + '&servid=' + servid,
        success: function (msg) {
            var obj = jQuery.parseJSON(msg);
            alert('' + obj.answer);
            setTimeout(function () {
                $.ajax({
                    type: 'GET',
                    async: true,
                    url: 'send_email.php',
                    data: 'email=zolkazlk@gmail.com&type=' + servtype + '&person=' + staff_name + '&time=' + a + '&date=' + nap + ', ' + dateText,
                    success: function (msg) {
                        var obj = jQuery.parseJSON(msg);
                        alert('' + obj.answer);
                        $.modal.close();
                        window.setTimeout(function () {
                            jQuery('#receipt').modal()
                        }, 50);
                    }
                });
            }, 200);
        }
    });
});
  • 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-29T20:15:23+00:00Added an answer on May 29, 2026 at 8:15 pm
    $('#confirm').die('click').live('click', function(){....})
    

    Finally, in your success call back you can $('#confirm').die('click') it again.

    This solution makes you sure that there’s no any other unwanted event raising. I’m using this solution, because high safety. No doubt that it’s better to fix the problem instead of such hacks, but sometimes it’s very time consuming and you don’t like to trace your team member codes.

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

Sidebar

Related Questions

i use json_encode to send back data from php to jquery through ajax. and
I use $.post('ajax/test.php', function(data) { $('.result').html(data);}); to send data and retrieve information and show
I am trying to use jquery's ajax $.get(...) function to send a request to
I'm attempting to send a piece of data through jQuery .ajax() to a PHP
I'm trying to use jQuery's .AJAX function to send a request to IPINFODB's API
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
I use jQuery and AJAX to load content from links and forms into a
I am trying to use jQuery's ajax functionality to update data from a web
So I am trying to use jQuery to insert data from an ajax call.
I am converting a javascript/php/ajax application to use jQuery to ensure compatibility with browsers

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.