jeudi 26 novembre 2015

Ajax data disappeared when I come back

I make a html page and there is ajax call for get some data.

after success ajax call, I render to html element with the json data which is from the ajax call.

But, If I go to other page by click some link, and when I come back there is no data at all.

how can I preserve the data element when I come back from other page.

<!DOCTYPE HTML>
...
...
<body>
<div id='data'>
</div>
<a href='/next'> NEXT </a>
<script type='text/javascript'>
$.ajax({
    type : 'GET',
    url : '/data/user',
    ...
    ...
    success: function(json) {
        $('#data').append(json.username);
    }
    ...
</script>
</html>

When I click 'NEXT' and history back. the username is go away.




Aucun commentaire:

Enregistrer un commentaire