0

"jQuery.ajax is not a function error" is showing in console, this detailsmodal function is called from index.php file in button tag it is used as popup dialog box for information of a product.

footer.php

function detailsmodal(id){
                    var data = {"id":id};
                    jQuery.ajax({
                        method : "post",
                        url : <?php echo BASEURL; ?>+'include/detailsmodal.php',

                        data : data,
                        success : function(data){
                            jQuery('body').append(data);
                            jQuery('#details-modal').modal('toggle');
                        },
                        error : function(){
                            alert("something went worng");
                        }
                    });
                    }

index.php

<div class="col-mid-8">
            <div class="row">
                <h2 class="text-center">Featured Products</h2>
                <?php while($product = mysqli_fetch_assoc($featured)) : ?>
                <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>$<?php echo $product['list_price']; ?></s></p>
                    <p class="price">Our Price: $<?php echo $product['price']; ?></p>
                    <button type="button" class="btn btn-sm btn-success" onclick = "detailsmodal(<?php echo $product['id']; ?>)">Details
                    </button>
                </div>
                <?php endwhile; ?>
            </div>
        </div>

0 Answers0