When to use AJAX?

    I often see ajax neglect on various not-so-good sites. It happens like this: the authorization form takes the user to a separate page, which is written in capital letters: “ YOU ARE AUTHORIZED! "Or" YOUR MESSAGE WILL BE PUBLISHED AFTER CHECK BY THE MODERATOR". Why create such pages in reality? This page does not carry any semantic payload. The semantic load remained on the page from which the user went in order to write a comment or log in. And now, he may already have forgotten why he did it. I also did this once when I did not know what ajax is. These pages simply handled the $ _POST parameters, and when the user clicked F5 on such a page, the post request was sent again. I then understood that there was something wrong with this approach, but I couldn’t say exactly what.

    Or vice versa - unjustified use of ajax. For example, for a paginator - it can certainly be beautiful but not too functional, you won’t share the link with friends, and search engines, as far as I know JavaScript is not very digested.

    And recently, I formalized the rules for the use of ajax for myself, which I follow relentlessly:

    • Pages with useful information are generated without using ajax. Traditional pages are well indexed and have a beautiful, catchy URL that you can share with friends.
    • 2. All functional controls of the site only through ajax: adding comments, authorization form, switching site themes, etc. There is nothing for the user to show the page on which one line “Your blog theme has been changed!” - he already knows about it. In addition, the possibility of re-sending the post-request is excluded. (Yes, by the way, all ajax controls that change the state of the system must be sent via post, but this is the topic of another article.)

    Also popular now: