25 August 2010

Tutorial about loading page with AJAX between any HTML tags. We are using jQuery JavaScript library to do this.

Loading part of page with AJAX can be useful and it can even make web browsing faster, because you don't have to reload the whole page. But it requires JavaScript. If your page visitors are web administrators then you can require JavaScript. If your site is about flowers then you can't, because they probably don't even know what JavaScript is.

Loading the data:

This works only for HTTP protocol. This means that if you just open HTML file in your web browser and the address is "file://some/dir/file.html" then it won't work. First make sure you have something to load from your address. It can be any text container file: HTML, PHP or even url to your rss file. Here is and example code:
Source code viewer
  1. <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  2.  
  3. <div id="example"></div>
  4.  
  5. <!--This is the script part, change the URL and your'e ready to go-->
  6. $("#example").load("/url/to/somewhere");
  7.  
  8. </body></html>
Programming Language: HTML
If you want to try it without uploading then look into WAMPs, I suggest XAMPP. This solution works for every language: ASP, PHP, Python etc. Now you know how to make load pages or content dynamically using AJAX.