Assign ajax query to a variable

-4

             $(document).ready(function(){
	$('#tabela').empty(); //Limpando a tabela
	$.ajax({
		type:'post',		//Definimos o método HTTP usado
		dataType: 'json',	//Definimos o tipo de retorno
		url: 'getDados.php',//Definindo o arquivo onde serão buscados os dados
		success: function(dados){
			for(var i=0;dados.length>i;i++){
				//Adicionando registros retornados na tabela
				


				$('#tabela').append('<tr><td>'+dados[i].date+'</td><td>'+dados[i].result+'</td></tr>');
				
				
			    }
		    }
	    });
    });


$('#tabela').append('['+dados[i].date+', '+dados[i].result+'], ');  // o retorno que preciso é nesta configuração

           

I'm creating an ajax query and would need to get the result and put it in a variable, the code I found puts the result into a table, I've tried everything that is way and I can not put the return I need inside a variable.

I need this because I'll use the result to create a graph of google charts that update from time to time;

    
asked by anonymous 12.09.2018 / 02:16

1 answer

0

var array = [];

array = JSON.parse (data);

This is for the ajax return to go to an array

    
12.09.2018 / 03:05