Linked Questions

Popular Questions

Update variable value of view after getting updated value from ajax

Asked by At

I am getting updated variable value via ajax but unable to make it in loop at view, to show filtered product

in my controller i write:

 $response['output']  = $product;
 $response['status']  = "success";

This the response which i am able to get in console:

output: [{id: "26", pro_id: "P856", pimg_id: "110", cat_id: null, subcat_id: null, brand_id: null,…},…]
    0: {id: "26", pro_id: "P856", pimg_id: "110", cat_id: null, subcat_id: null, brand_id: null,…}
    1: {id: "27", pro_id: "P227", pimg_id: "111", cat_id: null, subcat_id: null, brand_id: null,…}
    2: {id: "28", pro_id: "P434", pimg_id: "112", cat_id: null, subcat_id: null, brand_id: null,…}
    status: "success"

this is my view code i which i want make it in loop after getting ajax response:

// calling product ariable and making in loop as defalut before ajax request send db->get_where('product_image', array('pro_id' => $product->pro_id))->result();

    if(!empty($productimage[0]->img_url)){ ?>


    <img src="<?php echo base_url(); ?>assets/img/product/<?php echo $productimage[0]->img_url ?>" alt="">


    <?php $img= $productimage[0]->img_url;  ?>
                        <?php  if (empty($productimage[1])) {
                                ?>
                            <div class="hover-content">
                                <a href="<?php echo base_url() ?>Web/single_pro?P=<?php echo $product->pro_id ?>"

class="hover-image"> assets/img/product/img_url ?>" alt=""> Web/single_pro?P=pro_id) ?>" class="hover-image"> assets/img/product/img_url ?>" alt="">

            <div class="product-contents">
                <h3 class="product__caption">
                                            <a href="<?php echo base_url() ?>Web/single_pro?P=<?php echo

base64_encode($product->pro_id) ?>">pro_name ?>

                <div class="product__price">

                    <span class="price--old"><?php if ($this->session->userdata('bchrate')){ ?>
                                <?php $curr = $this->session->userdata('bchcurrency');
                            $sym= $this->web_model->get_currency($curr); echo $sym->symbol; ?>  
                                <?php $rate=$this->session->userdata('rate');

$sp=$product->selling_price*$rate; echo floor($sp) ; ?> session->userdata('bchcurrency'); $sym= $this->web_model->get_currency($curr); echo $sym->symbol; ?>pro_price*$rate); ?> ₹pro_price; ?> ₹selling_price; ?>

                <input type="hidden" name="proid" value="<?php echo $product->pro_id;?>">
                <input type="hidden" name="pro_price" value="<?php echo $product->pro_price;?>">
                <input type="hidden" name="selling_price" value="<?php echo $product->selling_price;?>">
                <input type="hidden" name="discount" value="<?php echo $product->discount;?>">
                <input type="hidden" name="sku" value="<?php echo $product->pro_sku; ?>">
                <input type="hidden" name="cat" value="<?php echo $product->cat_name; ?>">
                <input type="hidden" name="subcat" value="<?php echo $product->subcat_name; ?>">
                <input type="hidden" name="brand" value="<?php echo $product->brand_name; ?>">
                <input type="hidden" name="pimg_id" value="<?php echo $product->pimg_id; ?>">
                <input type="hidden" name="pro_name" value="<?php echo $product->pro_name; ?>">
                <input type="hidden" name="pro_summery" value="<?php echo $product->pro_summery; ?>">
                <input type="hidden" name="pro_details" value="<?php echo $product->pro_details; ?>">
                <p class="product-info-para">
                    product description textt.
                </p>
                <?php $pro_id=$product->pro_id; ?>
                    <div class="product__btn">
                        <a href="<?php echo base_url()?>Web/fcart/?pid=<?php echo $pro_id;?>&img=<?php echo $img

;?>&name=pro_name;?>&price=selling_price; ?>" class="theme-btn-outlined--type-2">add to cart

        </div>
    </div>

    <?php endforeach; ?>





 <?php foreach($product as $product): ?>
    <div class="col-lg-6 col-sm-6 mb-30">
        <div class="belly-product">
            <div class="product__image">
                <?php
    $productimage = $this->db->get_where('product_image', array('pro_id' => $product->pro_id))->result();


    if(!empty($productimage[0]->img_url)){ ?>


    <img src="<?php echo base_url(); ?>assets/img/product/<?php echo $productimage[0]->img_url ?>" alt="">


    <?php $img= $productimage[0]->img_url;  ?>
                        <?php  if (empty($productimage[1])) {
                                ?>
                            <div class="hover-content">
                                <a href="<?php echo base_url() ?>Web/single_pro?P=<?php echo $product->pro_id ?>"

class="hover-image"> assets/img/product/img_url ?>" alt=""> Web/single_pro?P=pro_id) ?>" class="hover-image"> assets/img/product/img_url ?>" alt="">

            <div class="product-contents">
                <h3 class="product__caption">
                                            <a href="<?php echo base_url() ?>Web/single_pro?P=<?php echo

base64_encode($product->pro_id) ?>">pro_name ?>

                <div class="product__price">

                    <span class="price--old"><?php if ($this->session->userdata('bchrate')){ ?>
                                <?php $curr = $this->session->userdata('bchcurrency');
                            $sym= $this->web_model->get_currency($curr); echo $sym->symbol; ?>  
                                <?php $rate=$this->session->userdata('rate');

$sp=$product->selling_price*$rate; echo floor($sp) ; ?> session->userdata('bchcurrency'); $sym= $this->web_model->get_currency($curr); echo $sym->symbol; ?>pro_price*$rate); ?> ₹pro_price; ?> ₹selling_price; ?>

                <input type="hidden" name="proid" value="<?php echo $product->pro_id;?>">
                <input type="hidden" name="pro_price" value="<?php echo $product->pro_price;?>">
                <input type="hidden" name="selling_price" value="<?php echo $product->selling_price;?>">
                <input type="hidden" name="discount" value="<?php echo $product->discount;?>">
                <input type="hidden" name="sku" value="<?php echo $product->pro_sku; ?>">
                <input type="hidden" name="cat" value="<?php echo $product->cat_name; ?>">
                <input type="hidden" name="subcat" value="<?php echo $product->subcat_name; ?>">
                <input type="hidden" name="brand" value="<?php echo $product->brand_name; ?>">
                <input type="hidden" name="pimg_id" value="<?php echo $product->pimg_id; ?>">
                <input type="hidden" name="pro_name" value="<?php echo $product->pro_name; ?>">
                <input type="hidden" name="pro_summery" value="<?php echo $product->pro_summery; ?>">
                <input type="hidden" name="pro_details" value="<?php echo $product->pro_details; ?>">
                <p class="product-info-para">
                    Nunc facilisis sagittis ullamcorper. Proin lectus ipsum, gravida et mattis vulputate, tristique ut lectus. Sed et

lorem nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean eleifend laoreet congue. Viva..

pro_id; ?> Web/fcart/?pid=&img=&name=pro_name;?>&price=selling_price; ?>" class="theme-btn-outlined--type-2">add to cart

        </div>
    </div>

    <?php endforeach; ?>

Related Questions