javascript - AJAX Bootstrap Modal Not Showing -


i'm trying show following modal, body database driven. data isnt appearing in bootstrap modal. i've been looking @ far long , cant see issue!

modal

<div class="modal fade" id="eventdetailsmodal" tabindex="-1" role="dialog" aria-labelledby="membermodallabel" aria-hidden="true">     <div class="modal-dialog">         <div class="modal-content">             <div class="modal-header">                 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">close</span></button>                 <h4 class="modal-title" id="membermodallabel">event details</h4>             </div>             <div class="dash">              </div>          </div>     </div> </div> 

ajax

$('#eventdetailsmodal').on('show.bs.modal', function (event) {       var button = $(event.relatedtarget) // button triggered modal       var recipient = button.data('whatever') // extract info data-* attributes       var modal = $(this);       var datastring = recipient;          $.ajax({              type: "get",              url: "/getnearestpc.php",              data: {"foo": datastring},              cache: false,              success: function (data) {                  console.log(data);                  console.log(datastring);                  console.log(recipient);                  $('.dash').html(data);              },              error: function(err) {                  console.log(err);              }          });   }) 

getnearest.php

    //sql setup     $pc = $_get['foo'];   <div class="modal-body center" style="background-color: #ffffff">     <table id="preusertable" class="table table-striped table-hover table-curved" style="width: 100%;">         <thead>             <tr>                 <th style="color: #000000;">event</th>                 <th style="color: #000000;">postcode</th>             </tr>         </thead>         <tbody>          <?php             while ($row = $sdata->fetch(pdo::fetch_assoc)) {                 $school = $row['schoolurl'];                 $postcodefull = $row['postcode'];                 ?>                 <tr>                                         <td style="font-size: 1.1em;"><?php echo $school ?></td>                     <td style="font-size: 1.1em;"><?php echo $postcodefull ?></td>                 </tr>                 <?php             }         ?>         </tbody>     </table> </div> 

modal trigger

<a data-toggle="modal" data-target="#eventdetailsmodal" data-whatever="<?php echo $postcode ?>"> 

any great! show modal header no body

instead of populating on modal shown event, try doing on click event of <a>:

$('a').on('click', function (event) {    var button = $(this); // button triggered modal    var recipient = button.data('whatever'); // extract info data-* attributes    var modal = $("#eventdetailsmodal");    var datastring = recipient;      $.ajax({       type: "get",       url: "/getnearestpc.php",       data: {"foo": datastring},       cache: false,       success: function (data) {         console.log(data);         console.log(datastring);         console.log(recipient);         $('.dash').html(data);       },       error: function(err) {         console.log(err);       }     });    })


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -