How can I mantain my position on the page on refresh (AJAX)

后端 未结 2 375
难免孤独
难免孤独 2021-01-27 04:23

I know that this is only possible with AJAX, but i\'ve never worked with AJAX... On my website you can keep a list of the cards that you have from the game Magic, this is quite

相关标签:
2条回答
  • 2021-01-27 04:31

    During an insert add column with timestamp . And get data ascending order of timestamp. Display the card.it will not change.

    0 讨论(0)
  • 2021-01-27 04:34

    have you thought about using JS to do this?

    Note: This requires the JQuery plugin, there are many CDN you can get it from though, with google being one of the most reliable Here

    $(document).ready(function(){
        var storePosition = {     /// initializing the storeposition
            topCoordinate : null
        }
    
    
         storePosition.topCoordinate =  $(this).offset().top;   /// storing the position
    
    
        if(storePosition.topCoordinate !== 0){   // if we are at the top no point doing anything
    
         $("html, body").animate({"scrollTop":  storePosition.topCoordinate}, 500);
    
    
            }
    });
    

    courtesy of This question

    Also just a note... PLEASE stop using non parameterized queries. consider using MySQLi as its not much of a step up from MySql syntax and will give you some good practice with object orientated programming.

    0 讨论(0)
提交回复
热议问题