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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:51:47+00:00 2026-06-09T15:51:47+00:00

Here’s a bootstrap modal that I’m putting the result of AJAX request in <div

  • 0

Here’s a bootstrap modal that I’m putting the result of AJAX request in

<div class="modal hide" id="myModal">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">×</button>
    <h3>Modal header</h3>
  </div>
  <div id="modal-body"></div>
  <div class="modal-footer">
    <a href="#" class="btn" data-dismiss="modal">Close</a>
  </div>
</div>

The javascript code looks like this

<script type="text/javascript">
  $('#myModal').modal('hide');
  $('div.divBox a').click(function(){
    var vendor = $(this).text();
    console.log(vendor);
    $('#myModal').on('show', function(){          
      $.ajax({
        type: "GET",
        url: "ip.php",
        data: "id=" + vendor,
        success: function(html){
          $("#modal-body").html(html);              
        }
      });           
    });
  });
  $('#myModal').on('hide', function () {
    $("#modal-body").empty();
    <?php unset($_GET); ?>;
  })
</script>

the ip.php file is

The anchor links code looks like this

           <tbody>
              <?php foreach ($rowarr as $k => $v) { ?>
                <tr>
                  <td><?php echo $k ?></td>
                  <td>
                    <div class="divBox">
                      <a data-toggle="modal" href="#myModal"><?php echo $v; ?></a>
                    </div>
                  </td>
                </tr>
              <?php } ?>
            </tbody>

$k is a number. $v is a name with spaces and special characters.

console.log(vendor) shows me the text of the link I clicked in CDT. But the output of the modal changes. It goes through all the links text I clicked previously, and keeps replacing them and finally ends up at the most current link text.

So if clicked the links in this order the console output looks like this

Microsoft Corporation
IBM Corp
Hewlett-Packard
Apple

The text in the modal will start out as

Array ( [id] => Microsoft Corporation )

then replace with

Array ( [id] => IBM Corp )

then replace with

Array ( [id] => Hewlett-Packard)

then end up with

Array ( [id] => Apple )

What is keeping track of the links clicked on the page ? Do I need to reset it every time a new link is clicked ?

EDIT: In response to “What have you tried?”

I added the $("#modal-body").empty(); in there in hope that maybe it’s the modal body that I need to cleared. That wasn’t it. Then I thought maybe the GET variable need to be reset on closing of the modal, so I added the <?php unset($_GET); ?>;. But the print_r($_GET) shows that the array only contains one array element, not all the links clicked previously. So I can’t figure where else the history of the links clicked be stored.

  • 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-09T15:51:49+00:00Added an answer on June 9, 2026 at 3:51 pm

    So basically, each time you click a divBox link, it adds a new handler to the myModal ‘show’ event. So basically after clicking 5 differentdivBox links, myModal‘s show event will cycle through 5 different handler functions.

    Basically you need to remove the previously added ‘show’ handler before adding a new one.

    $('#myModal').off('show');
    

    Best way to remove an event handler in jQuery?

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

Sidebar

Related Questions

here Html given below <div class=navBulletsWrapper> <div rel=0 class=></div> <div rel=1 class=></div> <div rel=2
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here's some sample HTML <style> .icon {display:none;} </style> <ul> <li>ABC <i id=abc class=icon>x</i></li> <li>DEF
Here are my functions: function dropmenu() { $(.dropdownitem).show('slow'); } function hidemenu() { $(.dropdownitem).hide('slow'); }
Here is the final result of what my page is(not much fancy stuff yet):
Here is my AsyncTask. Getting exception in the AsyncTask.. private class GetCategories extends AsyncTask<String,
Here's the setup - I have a view that lists products. On that same
Here is a scenario: User installs .NET application that you have made. After some
Here's a sample of a SpinBox that writes its changes to underlying variables. The
Here is my code for the POST request to the server. The JSON to

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.