trizh — 2013-06-26T21:55:03-04:00 — #1
I want a div to load only if you click a link. This way my site pages will load faster...
<a href="#">load me</a>
lots of contents here to load on click
pullo — 2013-06-27T04:12:25-04:00 — #2
Welcome to the forums
This sounds like a job for AJAX.
Are you using, or do you mind using jQuery?
trizh — 2013-06-27T12:00:34-04:00 — #3
Thanks for ur reply sir
I will use it into site hosted in blogger. I really don't know what's their difference... as long as it works it's fine with me
pullo — 2013-06-27T15:39:00-04:00 — #4
jQuery is often overkill for small projects, but it does offer a simplified syntax for AJAX stuff, so I'll use it here.
What we need to do is to make a HTML template, include the jQuery library and attach an event handler to the link that will be responsible for loading the content into the div.
After that we need to create a file that will hold the content we will be loading.
I'll call mine content.html.
Then we can use jQuery's
.load() method to load the content from content.html into the div.
The whole thing looks like this:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<a href="#" id="myLink">Click me!</a>
<div id="result">The text will get loaded here</div>
You might also find this useful: http://api.jquery.com/load/
system — 2014-10-08T00:28:30-04:00 — #5
This topic is now closed. New replies are no longer allowed.