Pass data received in JSON to another page

0

I have the code below where I get a JSON file and display 2 fields of it:

$.getJSON('www.site.com.br/arquivo.json', function(data){

    this.qtd = data.json.length;
    this.retorno = '';

    for(i in data.json){
        this.retorno += 'Nome: ' + data.json[i].nome + '<br />';

        for (j in data.json[i].amigos){
            this.retorno += 'TXT: ' + data.json[i].amigos[j].amigo + '<br />';
        }    

        this.retorno += '<br />';
    }                       

    $('#resultado').html(this.retorno);
});

I would like to put a link like "see +" and the user clicks to go to a new page where, besides showing the two fields that are being displayed (name and friend), bring the rest of their content as address, tel , etc. (this data is in JSON).

How can I create this link and receive data only from the person I want on the other page?

Thank you.

    
asked by anonymous 22.11.2017 / 17:54

1 answer

0

Vinicius, I was able to put the link as you explained:

$.getJSON('www.site.com.br/arquivo.json', function(data){
		
	this.qtd = data.json.length;
	this.retorno = '';

	for(i in data.json){
    	this.retorno += 'Nome: ' + data.json[i].nome + '<br />';

        for (j in data.json[i].amigos){
            this.retorno += 'TXT: ' + data.json[i].amigos[j].amigo + '<br />';
        }    

        this.retorno += '<a href="detalhes.html?nome=' + data.json[i].nome + '">Veja +</a><br />';

        this.retorno += '<br />';
    }						

	$('#resultado').html(this.retorno);
});

Just how do I get on a new page, in that case the details.html the contents of this JSON?

That is, if it were in PHP I would receive a POST or GET and okay, but only with JavaScript is it possible to receive the details.html?

Thank you.

    
23.11.2017 / 16:22