Discussion: javascript and jquery
3 messages from 3 displayed.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
Please, use the button between a smiley and B - it's for a
code. Paste your code again between the code
tags, because now it's
very unreadable.
<!--main page content-->
<div class="col-md-8"> <!--loads the content dynamically from the database-->
<div class="row">
<h2 class="text-center">Featured Products</h2>
<?php while ($product = mysqli_fetch_assoc($r)):?>
<div class="col-md-3">
<h4><?php echo $product['title'];?></h4>
<img src="<?php echo $product['image'];?>" alt="<?php echo $product['title'];?>" class="img-thumb"/>
<p class="list-price text-danger">list price: <s> Ksh<?php echo $product['list_price'];?></s></p>
<p class="price">Our price:Ksh<?php echo $product['price'];?></p>
<button type="button" class="btn btn-success" onclick="detailsmodal(<? $product['id']?>)"> Details</button>
</div>
<?php endwhile;?>
</div>
</div>
Javascript
<script>
function detailsmodal(id){
var data = {id;
jQuery.ajax({
url: <?=BASEURL;?>+ 'includes/detailsmodal.php',
method: "post",
data: data,
success: function(){
jQuery('body').append(data);
jQuery('#details-modal').modal('toggle');
},
error: function(){
alert("something went wrong");
}
});
}
</script>
3 messages from 3 displayed.