Question: I have several update methods in a javascript file, used for updating my ajax application, like so:

```
function updateByPk(layer, pk) {
   url = "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random();
   update(layer, url);
}

function updateByQuery(layer, query) {
   url = "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random();
   update(layer, url);
}

function updateByPage(layer, query, pg) {
   url = "get_records.php?cmd=GetRecordSet&query="+query+"&pg="+pg+"&sid="+Math.random();
   update(layer, url);
}

```

I am wondering if it would be more efficient to do things like pagination and such strictly through php, simply by reloading the page, rather than using an ajax method. I am not sure which method is more efficient, or if there are advantages and disadvantages to each.

Answer: 
if I get the question, then you're asking whether pagination, and similar, is better to be done through Javascript + AJAX, or to be done through a call to the server?

I'd personally say to just use a request to the server. AJAX is uneccesary in cases like this, other than for "bling" factor (yes, that is a technical term :P )

If you're writing the app correctly with accessibility in mind, you should HAVE to write the "direct call to the server" bit anyway (for when someone has Javascript turned off and clicks on one of your "next page" links.

Having the Javascript there means that 1) you've got extra code to maintain. 2) you break the back button. If you only implement the AJAX method, then you have no way of accessing the data on other pages. And you've no easy way of linking to it (by copying the address bar) if you do.

I will personally only ever use AJAX for things that are going to add functionality to the page, without taking any other functionality away, for example, checking if a username is taken when filling in a registration form. Auto-suggest, etc etc.
It depends on your definition of efficiency. Loading new content through AJAX will net less bytes going over the wire, but might be more strenuous on your server if you can't cache the dynamic content into static files (which I assume you would when reloading the page). However relying on AJAX too much might cause your pages to be less accessible for users whose browsers don't support javascript (they exist) and might hurt your sites capability to be indexed by search engines. A best of both worlds scenario would be to let the links point to a reloaded page, but override that behaviour with javascript to load in new content through AJAX.