I
I
I'm Yoda2017-03-26 12:06:30
PHP
I'm Yoda, 2017-03-26 12:06:30

How to filter data received via ajax request in a modal window?

I send data to the modal window via ajax request:
When you click on div.item-selector, a modal window opens with the selected element and images similar in parameters are displayed.

...
            <div class="grid-item <?= $color_id . ' ' . $structure_id ?>" id="<?= $strMainID; ?>">
                <div class="item-box">
                    <input type="hidden" value="<?= $itemid; ?>" id="data_id"/>
                    <input type="hidden" value="<?= $name; ?>" id="data_name"/>
                    <input type="hidden" value="<?= $image; ?>" id="data_picture"/>
                    <input type="hidden" value="<?= $color; ?>" id="data_color"/>
                    <input type="hidden" value="<?= $structure; ?>" id="data_structure"/>
                    <div class="item-selector">
                        <img src="<?= $image; ?>" class="image"/>
                        <p class="text-center">
                            <?= $name; ?>
                        </p>                        
                    </div>
                </div>
            </div>
...

$(document).ready(function () {
            $(".item-selector").click(function () {

                var data_id = $(this).parent('.item-box').find('#data_id').attr('value');
                var data_name = $(this).parent('.item-box').find('#data_name').attr('value');
                var data_picture = $(this).parent('.item-box').find('#data_picture').attr('value');
                var data_color = $(this).parent('.item-box').find('#data_color').attr('value');
                var data_structure = $(this).parent('.item-box').find('#data_structure').attr('value');

                $.ajax({
                    type: 'get',
                    url: 'ajax.php',
                    data: {
                        'data_id': data_id,
                        'data_name': data_name,
                        'data_picture': data_picture,
                        'data_color': data_color,
                        'data_structure': data_structure
                    },
                    response: 'text',
                    success: function (data) {
                        $('.popup-box').html(data);
                    }
                });
            });
        });

All elements before applying the filter:
a29746982545470694936f3fabe3c1fc.jpg
Elements are filtered and displayed in the modal window:
cacb17345952488eaf6e15cfbc74aa51.jpg
How to continue working in the modal window so that when you click on any of the results, the big picture is replaced and similar results are displayed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question