Transmit information between html pages with jQuery?

Asked

Viewed 89 times

1

Good afternoon, all right?

In my project, I have a list of properties, all different from each other. When clicking on any of them, one should open a page of details with unique information regarding the property clicked. The problem is communicating my results page with the details page.

I had in mind to make communication through an id... Look at my example:

<!-- RESULTADO.html -->
    <ul id="resultado-pesquisa">
        <li class="itens-pesquisa"><a id="0101" >Clicar para detalhes</a></li>
        <li class="itens-pesquisa"><a id="0202" >Clicar para detalhes</a></li>
        <li class="itens-pesquisa"><a id="0303" >Clicar para detalhes</a></li>
    </ul>

What I need is: Click on the anchor and go to id to the details page via jQuery! It is possible?

Thank you, good week everyone!

1 answer

1


@Joao Souza can do with hash, so do not operate with cookies for this:

<ul id="resultado-pesquisa">
    <li class="itens-pesquisa"><a id="0101" href="detalhes.html#0101">Clicar para detalhes</a></li>
    <li class="itens-pesquisa"><a id="0202" href="detalhes.html#0202">Clicar para detalhes</a></li>
    <li class="itens-pesquisa"><a id="0303" href="detalhes.html#0303">Clicar para detalhes</a></li>
</ul>

Then on the page detalhes.html, can get the id on href where you clicked on the previous page, for example on page detalhes.html#0101:

var id_imovel = location.hash;
console.log(id_imovel); // #0101 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.