I have somewhat of a thought question regarding jQuery Ajax. My question is this: If I load just one section of an HTML into a div using jQuery Ajax, like this:
$('#result').load('ajax/test.html #container');
Will the user have to download the entire test.html in order to see what the #container div has? In other words, will the entire test.html file be downloaded and then parsed to only select the #container div, or will only the #container div be downloaded? If the first happens, can you think of any way of only downloading the #container div without creating a new html file?
Thank you so much for your input! 🙂 I really appreciate it.
Certainly the whole HTML will be downloaded.
If you want to avoid this, you have to create some kind of serverside script, for example PHP, that will only send the required content.
You could call it with something like
and in the PHP check for the existence of
$_GET['ajax'], and if it exists, only send the#containerdiv.