May 2017
Intermediate to advanced
448 pages
10h 10m
English
This setup is simple, but requires a page refresh for each sort operation. As we have seen, jQuery allows us to eliminate such page refreshes by using Ajax methods. If we have the column headers set up as links as before, we can add jQuery code that will translate those links into Ajax requests:
$(() => { $('#my-data th a') .click((e) => { e.preventDefault(); $('#my-data tbody') .load($(e.target).attr('href')); }); });
Now when the anchors are clicked, jQuery sends an Ajax request to the server for the same page. When jQuery is used to make a page request using Ajax, it sets the X-Requested-With HTTP header to XMLHttpRequest so that the server can determine that an Ajax request is being made. The server code ...
Read now
Unlock full access