how do I preload the data response with ajax

0

Hello, please, you could help me explaining how to make the response from php load first before being shown to the client, I want the load next to the client to be faster and not look like.

php 'include ("conexion_bd.php");

$result = mysqli_query($con,"SELECT * FROM tarot ORDER BY RAND() LIMIT 78");




while($row = mysqli_fetch_array($result)){

    $cartaNombre = $row["Carta"];

    echo "<input type='image' src='$cartaNombre' value='$cartaNombre' alt='no se encuentra' width='7%' class='cartas' name='carta' onclick='this.disabled = true; valor(value)'>";

}

mysqli_free_result($result);



mysqli_close($con);'

ajax

$.ajax({
            type: "POST",
            url: "baraja.php",
            success: function(response)
        {
            $('.baraja').html(response).fadeIn();
        }

       });

muchas gracias 

I hope you make me understand help me please

    
asked by gabo luna 26.04.2017 в 15:38
source

1 answer

0

I think what you need to do is to load those images and then manipulate them with javascript. I advise you to do the following.

$(document).ready(function () {
    var respuesta='';
    $.ajax({
            type: "POST",
            url: "baraja.php",
            async: false,//Esto hace que deba esperar esta peticion para proseguir

            success: function(response)
        {
            respuesta=response;
            $('.baraja').html(response).fadeIn();
        }

       });

    //Aqui todo el codigo que se debe ejecutar despues de la peticion
    //se puede manipular la respuesta a a gusto y antojo

} );
    
answered by 26.04.2017 в 18:07