JSON n HTML is recognized for plugins

Asked

Viewed 20 times

0

I made a JSON calling a database info, however I went to use a plugin of slide and it doesn’t work. But it seems q isn’t just him, with other types of function as well, it seems that he doesn’t recognize the id or class. But if I do HTML normal, works.

<div class="swiper-container" id="leitor">
    <div id="leitor2"></div>
    <!-- Add Pagination -->
    <div class="swiper-pagination swiper-pagination-white"></div>
    <!-- Add Navigation -->
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>
</div>

<!-- Swiper JS -->
<script src="js/jquery.min.js"></script>
<script src="js/app.js"></script>
<script src="js/materialize.min.js"></script>
<script src="js/swiper.js"></script>
<script src="js/swiper.min.js"></script>
<script src="js/swiper.esm.js"></script>
<script src="js/swiper.esm.bundle.js"></script>

<!-- Initialize Swiper -->
<script  type="text/javascript">
    $(document).ready(function () {
        var swiper = new Swiper('.swiper-container', {
            zoom: true,
            lazy: true,
            pagination: {
                el: '.swiper-pagination',
            },
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
            },
        });
    });
</script>

$(document).ready(function(){
  var container = $("#leitor");
  var lista = container.find("#leitor2");
  var html = '';


  var query = location.search.slice(1);
  var partesDaQuery = query.split("&");
  var json = {};

    partesDaQuery.forEach(function(partes){
        var chaveValor = partes.split('=');
        var paramsKey = chaveValor[0];
        var paramsValue = chaveValor[1];
        json[paramsKey] = paramsValue;

        $.getJSON('http://teste.com/app2.php?id='+json[paramsKey], 
            function(data){
                $.each(data, function(k, v){
                html +=  '<div class="swiper-slide">';
                html +=    '<div class="swiper-zoom-container">';
                //Essa parte da imagem ainda não acabei.
                  html +=    
                    '<img src="http://teste.com/leitor/capa/'+v.titulo+'/170/01.jpg" class="swiper-lazy">';
                  html +=     
                    '<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>';
                  html += '</div>';
                    });
                lista.html(html);
        });

    });
});

  • Are you talking about this getJSON at the end? And what is the JSON it’s getting?

  • Yes. So JSON is working, but the script seems q n recognizes the class q is inside this JSON. Ai I cannot zoom in on the image, nor pass it: <script type="text/javascript"> $(Document). ready(Function() { var Swiper = new Swiper('.Swiper-container', { zoom: true, Lazy: true, pagination: { el: '.Swiper-pagination', }, navigation: { Nextel: '.Swiper-button-next', prevEl: '.Swiper-button-Prev', }, }); }); </script>

  • What do you mean "class within this JSON"? Are you sure you are delivering valid JSON to Javascript?

  • I think so. I’m playing agr with JSON. If you have a better example to use. The class I referred to would be this one: http://prntscr.com/hjkghc

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.