PHP Ajax shows no results (CLOSED)

0

I need help with my php code, I do not know if I'm doing it right but ... I have this script:

$('#procesaPedido').on('click', function() {
        var storage = {};
        for ( var i = 0, len = localStorage.length; i < len; ++i ) {
            var key = localStorage.key(i);
            storage[localStorage.key( i )] = localStorage[key];
        }       
        var carritojs=JSON.stringify(storage);
        $.ajax({
            type:"POST",
            data:{"carrito":carritojs},
            success:function(data){
                console.log("enviado");
            }
        });
    });

and it is sent to the same page that is php where I have:

<?php
          if(isset($_POST['carrito'])) 
          {
            echo $_POST['carrito'];
            exit;
          }
        ?>

This does not show me the echo, I do not know if the item did not arrive at php or if I can not show it in this way it helps

    
asked by Gabriel Rodriguez 23.07.2018 в 18:58
source

0 answers