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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:09:48+00:00 2026-06-01T00:09:48+00:00

I am using the script code below to get results from my database based

  • 0

I am using the script code below to get results from my database based on the ID of a button when the user clicks it. The database results return fine in the form alert(msg) I am testing as an output. Could someone please help as to how I might return in the results in a modal window instead? I am using bootstrap for my application which uses bootstrap-modal.js, I can’t figure out how I might integrate the two scripts.

<script type="text/javascript">
   $(document).ready(function() {
     $(function() {
       $('.ajax-link').click( function() {
        $.get( $(this).attr('href'), function(msg) {
          alert(msg);
        });
        return false; // don't follow the link!
      });
    });
  });
</script>

Example of a bootstrap modal call:

<script>
  $(function() {
    $('#userGuide').modal({
    backdrop: true;
  });
});
</script>

UPDATE: This is the code on the page I am trying to return the user #userGuide from using $.get based on the ID of the button clicked:

    <?php

    //MySQL Database Connect
    require 'config.php';

    $id = $_GET["id"];
    $stmt = $dbh->prepare('CALL sp_get_recipe_items(:id)');
    $stmt->bindParam(':id',$id,PDO::PARAM_INT,4000);
    $res = $stmt->execute();

    if ($res){
        while( $row = $stmt->fetchObject() ){
            echo "<div id='userGuide' class='modal hide fade'><div class='modal-body'>".$row->Ingredient."&nbsp;".$row->Quantity."&nbsp;".$row->UoM."&nbsp;</div></div>";
            }

    }else{
    $arr = $sth->errorInfo();
    echo "Execution failed with MYSQL: " . $arr[0] . "\n";
    die();
    }                      

?>
  • 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-01T00:09:49+00:00Added an answer on June 1, 2026 at 12:09 am

    Try

    $(document).ready(function() {
        $('.ajax-link').click(function(event) {
            $('#container').load($(this).attr('href'), function() {
                $('#container').modal({
                    backdrop: true
                });
            });
            event.preventDefault();
        });
    });​
    

    This uses the .load() method to load content into the container element, so you need to add a new element on the page:

    <div id="container" style="display:none"></div>
    

    then uses the callback to show the dialog (.modal()) using the container. As you are returning multiple <div>s you need to add them to a container before making that the dialog.

    Also added the event parameter to the click callback function and using preventDefault() instead of return false.

    Note that

    $(document).ready(function() {
    

    and

    $(function() {
    

    do the same thing – the second is short hand for the first.

    Update

    If you look at the docs for the modal window you will see the markup needs to be

    <div class="modal" id="myModal">
      <div class="modal-body">
       <div>Butter & nbsp; 45 & nbsp; grams & nbsp;</div>
       <div>Flour & nbsp; 12 & nbsp; grams & nbsp;</div>
      </div>
    </div>
    

    then you use $('#myModal').modal(options) to show the window ….

    So i suggest you try this, first edit your PHP loop :

    echo "<div class='modal-body'>";
    while( $row = $stmt->fetchObject() ){
       echo "<div>".$row->Ingredient."&nbsp;".$row->Quantity."&nbsp;".$row->UoM."&nbsp;</div>";
    }
    echo "</div>";
    

    this will create the body of the window … then already on your page have this :

    <div id="modal-container" class="modal"></div>
    

    and finally your JavaScript :

    $(document).ready(function() {
        $('.ajax-link').click(function(event) {
            $('#modal-container').load($(this).attr('href'), function() {
                $('#modal-container').modal({
                    backdrop: true
                });
            });
            event.preventDefault();
        });
    });​
    

    Then your not duplicating any ids and loading the content into an already existing container.

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

Sidebar

Related Questions

I want to enable auto update script in flex3. i am using below code
I' m trying to enable adding/deleting rows to/from table using folowing code: Script: $(document).ready(function()
I am using a simple live search script that displays the results from a
I have a very small script to get all records from a database table,
I have the following snippet below from my script that's using a WebRequest to
I am using the following code as part of an autocomplete script to avoid
I'm using the following JavaScript code: <script language=JavaScript1.2 type=text/javascript> function CreateBookmarkLink(title, url) { if
I want to call shell script on windows environment using java code. I am
I have this code to show a map using the Virtual Earth API: <script
Im using jquery 1.3.2 and this is the code: <script type=text/javascript> //<![CDATA[ jQuery(function(){ jQuery('.news_bullet

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.