In general, I decided to make only the central part of the site change, i.e. when you click on a link, for example "http://site.ru/fb.php", using js, the transition to the page is blocked, then a request is made via Ajax to the php file, which opens that page and remembers its html code, but opens it with a parameter, those. "fb.php? js". And there is already a check if this parameter is present, then it is not necessary to load the header, footer, etc., only the content. and then use js to change the contents of the content block. My question is: is it possible to make a progress bar when uploading content so that it is a direct percentage? And is it even better than a regular transition, or are there any shortcomings, is everything properly designed for me?
3 answers
Designed correctly, the only thing that you forgot to write in the history of ajax links (vertical), which as a result will lead to incorrect navigation in the browser, links for older browsers are written into a hash with further tracking of its changes, for new ones use pushState and popstate event .
At the expense of interest (I don’t know myself here), if it is possible, it’s only on html5, but I don’t see any sense in it, because personally, in my engine, requests take an average of 150ms.
If you don’t have any special flaws, search engines will quietly index content, only events on loaded elements (including ajax-links) will have to be re-assigned (if you use jquery, use the live function instead of bind), from the pros - time will decrease content updates and server loading.
- Thank you. you need to update the link when you go to the page, for example, you go from the index.php page to the fb.php page, then make it in the browser line so that it is site.ru/index.php#fb.php and in such cases when you click back in the browser / will the right action take place? + I forgot to specify that when entering a page, you can save content to a variable, and when you re-enter this page, you can’t load it with ajax again - this is how to do it right? - iproger 2:07 pm
- browsers have local storage, I personally did not use it and generally I have it in distant plans, so I will not advise anything, but in theory you will need to create an object in which the property name will be the same as the link to the content, and then you can easily make a check to prevent reloading - RedMonkey
- Clear, thanks - iproger
1) As far as I know, without ActiveScript (Flash) this is impossible. I can be wrong.
1.1) Look in the direction of synchronous loading, maybe there is a solution.
2) Ajax does not provide for the use of whole pages for loading, it was created to send requests in small portions. Therefore, to use it as a total preloader is a very controversial issue.
- bue niachem no offense. - Artem
Dig in the direction of the history handler, it seems to me in two ways, catch get and from it form a request to the Ajax, further connect the history, and update the header with the necessary hash, these parameters can be passed through for example date attributes