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

  • Home
  • SEARCH
  • 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 8392893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:38:25+00:00 2026-06-09T19:38:25+00:00

I have a small problem in my code. I have a function, which require

  • 0

I have a small problem in my code.
I have a function, which require loadData AJAX page.
This result puts checkboxes on my pages. (this is OK)

Now I want when I click a checkbox, executes an AJAX request is to change a value in the database (this is also ok).

The problem is:
When I click on a checkbox (unchecked) it tick and execute the ajax, once the ajax executed, the box is uncheck all alone.

I made several tests and I realized that the problem occurs only when the checked boxes from an Ajax request.

Note : I’ve tried to add the $(selector).attr(‘checked’, true) and false, but nothing work.

Jquery (The Problem is in loadData Function when Ajax is executed, the checkbox uncheck alone) :

 $(document).ready(function()  {
    $('#TableContainer .RCkbox').live('click',function(){

        var idOperation = 550;
        if($(this).is(":checked")){

            $.ajax({
                type: "POST",
                url: "includes/ajax/OperationRapprochement.php",
                data: "sessionId=" + <?php echo $User->getId(); ?> + "&AccountNumber=" + <?php echo $compte->getId(); ?> + "&idOperation=" + idOperation + "&action=rapproche",
                success: function(msg)
                {
                    //TODO  

                }
            });
        }
        else{

                $.ajax({
                type: "POST",
                url: "includes/ajax/OperationRapprochement.php",
                data: "sessionId=" + <?php echo $User->getId(); ?> + "&AccountNumber=" + <?php echo $compte->getId(); ?> + "&idOperation=" + idOperation + "&action=derapproche",
                success: function(msg)
                {
                      //TODO

                }
            });
       }
    });


    function loadData(){
    $.ajax({
            type: "POST",
            url: "includes/ajax/test.php",
            data: "sessionId=" + <?php echo $User->getId(); ?> + "&AccountNumber=" + <?php echo $compte->getId(); ?>,
            success: function(msg){
                    $("#TableContainer").ajaxComplete(function(event, request, settings){
                           $("#TableContainer").html(msg);
                    });
            }
        });
    }

    loadData();
});

I’ve make video to show you the problem in action : http://youtu.be/nG9XF2f4M18

Thanks for your help.

  • 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-09T19:38:27+00:00Added an answer on June 9, 2026 at 7:38 pm

    ** Answer was updated from the information I got in the comments **

    I found the problem in your files.

    The thing is that you use the event “.ajaxComplete”.
    If you read the documentation correctly, it says that the event gets call everytime an ajax call gets made.

    So since you make an ajax call when you click on a checkbox, when you receive the result, the callback in the loadData function gets called again meaning that it executes $("#TableContainer").html(msg); again… in other words, it replaces the content again.
    That’s why you lose the checked checkboxes.

    All you have to change in your code is remove the events .ajaxComplete since you don’t need them.

    This is your code:

    function loadData(){
        $.ajax
        ({
            type: "POST",
            url: "includes/ajax/test.php",
            data: "number=" + number,
            success: function(msg)
            {
                $("#TableContainer").ajaxComplete(function(event, request, settings) {
                    $("#TableContainer").html(msg);
                });
            }
        });
    }
    

    It should be:

    function loadData(){
        $.ajax
        ({
            type: "POST",
            url: "includes/ajax/test.php",
            data: "number=" + number,
            success: function(msg)
            {
                    $("#TableContainer").html(msg);
            }
        });
    }
    

    Same thing for your other 2 ajax requests.
    The code in success gets executed when it receives a result.

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

Sidebar

Related Questions

I have a small problem with jQuery $.ajax() function. I have a form where
Im having a small problem with my code. I have been trying to read
Here a small piece of code for testing and explain the problem. I have
I have a small problem which i can't seem to figure out. I tried
I have a small problem which i can't seem to solve myself. Look at
I have a small problem - I want to decrease code duplication in my
I have made a small function which should print some InfoPath files. It is
I have a small ajax jquery script which returns some XML for me. Whilst
I have a small problem which I can't seem to find a solution to.
I have a small problem, which I think it will be easy for you

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.