Skip to content Skip to sidebar Skip to footer

Replace Php Content With Div

When a user clicks on product image ajax send id of product to PHP. PHP find product in MySQL database and fills data into HTML. The problem is when PHP fill data that data do not

Solution 1:

Your will get HTML on ajax response. Then you can use that Ajax response in your Ajax success function and can append that wherever you want as below:

$(document).on("click touchend", ".product_stake_stapovi, .product_invalidska_kolica, .product_antidekubitni_program, .product_ortoze, .product_mideri, .product_pojas, .product_toaletni_program, .product_bolnicki_kreveti_i_oprema", function (event) {
        var product_num_id = $(this).children(".num_id").attr("id"); //Getting id from image element (that is location of real stored id in database)
        var product_id = $(this).attr("class");
        var product_real_id = product_id.replace("col-3 col ", ""); 
        $.ajax({
            method: "POST",
            url: "index.php?proizvodi",
            data: ({product_num_id:product_num_id}),
            success: function(data) {
                alert(data) //It will have your HTML, you can use this HTML wherever you want.
                //console.log(product_num_id);
                $(".big_categoryes").fadeOut("fast");
                $(".all_products").fadeOut("fast");
                $(".product_view_info").fadeIn("smooth");

            }
        });
    });

Hope it helps you!!


Post a Comment for "Replace Php Content With Div"