Poornima Poornima -4 years ago 140
jQuery Question

unable to get href Attributes using JQuery

Below is my PHP code. I am displaying 3 images, if I Click over any image or product I need to add that product in the popup modal. I am trying to get the product name but I can't. How to solve this issue.

$i = 0;
while ($row = mysql_fetch_assoc($result))
echo"<td style='background-color:#FFFFFF;' height='383'>
<a href='#myModal?productname={$row["productname"]} 'id='burl' role='button' data-productname='{$row["productname"]}' data-toggle='modal' data-target='#myModal'>
<img src='images/{$row["productname"]}.jpg' width='255'/>

JQuery Codings:

$(document).ready(function () {
$('#myModal').on('shown.bs.modal', function () {

Answer Source
 $(document).ready(function ()
            $('#myPopup').on('show.bs.modal', function (e) 
                var rowid = $(e.relatedTarget).data('productname');
                    type: 'GET',
                    url: 'fetch_data.php', //Here you will fetch records
                    data: 'productname=' + rowid, //Pass $id
                    success: function (data)
                        $('.fetched-data').html(data);//Show fetched data from database                      

This coding solved my problem.
Thanks for all your reply.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download