After php query open result in a new page

1

How can I, if I can, open a new page after returning a query in php , what I have today is this:

$(function () {
$("#frmConsulta").validate({
    submitHandler: function (form) {

        var data = $(form).serialize();
        console.log(data);  

        $.ajax({
            type: 'POST',
            url: 'ajax/pRelatorioEvolucaoSafra.php',
            data: data,
            dataType: 'html',

            success: function (response) {

                // EXIBINDO O RETORNO DAS INFORMAÇÕES   
                $("#msgRelatorio").html(response);

                $('#frmConsulta').each(function () {
                    this.reset();
                });
            },
            error: function (xhr, ajaxOptions, thrownError) {
                console.log(xhr, ajaxOptions, thrownError);
                $("#msgRelatorio").html('<div class="alert alert-danger fade in"><button class="close" data-dismiss="alert">×</button><i class="fa-fw fa fa-times"></i><strong>ATENÇÃO!</strong> Ocorreu um erro ao tentar efetuar a consulta. Contate o suporte técnico.</div>');
            }
        });
        return false;
    }
});

});

In return, I'm placing a table in the% div, but I need to open it in a new page.

    
asked by anonymous 12.07.2017 / 22:57

1 answer

1

As commented by Anderson Carlos Woss. The correct thing to do is an asynchronous request. But anyway, you can do this using LocalStorage :

success: function (response) {
    localStorage.setItem('nome_salvo', JSON.stringify(response));
    // JSON.stringify para transformar os dados em formato JSON
}

And on the other page just pick up the data:

var consulta = JSON.parse(localStorage.getItem('nome_salvo'));
//JSON.parse transforma dos dados em JSON para Objetos
// Dessa forma você pode acessar os dados assim: consulta.nome

After collecting the data, delete it:

localStorage.removeItem('nome_salvo');
    
13.07.2017 / 14:10