Why not just using ajax for Page Requests to load the page content?

后端 未结 9 1017
醉话见心
醉话见心 2021-01-13 07:47

Many web pages load all of their content to change very little information.

Now I would like to know why shouldn\'t the developers just use ajax for the main page re

9条回答
  •  清歌不尽
    2021-01-13 08:22

    Well, you can always add the onclick event unobtrusively using jquery and stop the normal URL handling.

    Eg:

    HTML

    Click me to do AJAXy stuff if you have javascript
    

    then Javascript

    $(document).ready(function() {       
      $("#ajaxify-this").click( function(e) {
           updateContent(); // do something ajaxy with the page
           return false; // stop the click from causing navigation
       })
    }
    

提交回复
热议问题