Hacker News new | ask | show | jobs
by MisterWebz 5781 days ago
Excuse my ignorance, but i thought Ajax sends the whole page but only renders a part of the page?
2 comments

The server sends a client a whole page and once that page renders in a browser then you can use Ajax to transfer arbitrary bits of data to and from the server. You typically would not send an entire page to a client via Ajax, but you would use it to tell the server that 'User A' has voted on 'Story B' without having to load an entirely new page or refresh the page you're on.
If your Ajax code is reloading the whole page every time anything changes, that's some awful code. I have seen such designs in the wild, but that's just because whoever wrote the script was a lousy developer. It's not supposed to be that way.

Here's how Ajax works: A whole page is downloaded once from the server, then the page's Ajax functions start running — and then when part of the page needs to be updated, the Ajax toolkit only has to reload that specific data and render it on the page.