• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

Use JQuery Ajax to load static html page to a div tag ...

In one of my projects, I need to add several static pages to it. Those pages are static html and will not need update.

To make this separate from the main project which has a good MVC structure, I use JQuery’s Ajax function to load those static pages.

First of all, here is a menu from index.html page.

<ul>
 <li><a id="page1" href="#">About</a></li>
 <li><a id="page2" href="#">Community</a></li>
 <li><a id="page3" href="#">Sponsor</a></li>
</ul>
<div id="result" style="clear:both;">
</div>

At the head part, we need to include JQuery library.

<script src="http://code.jquery.com/jquery-1.4.min.js" type="text/javascript"></script>

Add the following code to head part.

 <script type="text/javascript">
  $(document).ready(function(){
     $("#page1").click(function(){
      $(#result).load(pages/page1.html);
       //alert("Thanks for visiting!");
     });
 
     $("#page2").click(function(){
      $(#result).load(pages/page2.html);
       //alert("Thanks for visiting!");
     });
   });
 </script>

That’s it! So simple. Of course, you have a directory /pages/ which contains several static html pages for loading.

 Original Source:
http://www.programcreek.com/2010/01/use-jquery-ajax-to-load-static-html-page-to-a-div-tag/

AddThis Social Bookmark Button

Posted at 09:30:32 am | Permalink | Posted in jQuery  

Related Stuff

  • MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.

  • Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone

  • TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support

  • ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.

  • Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.

  • Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software

  • PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.

Top Stuff

MessengerFX

e-messenger

ILoveIM

Top 20 Ruby CMS

eBuddy

MSN Web Messenger



About Ajaxlines

Ajaxlines is a project focused on providing its audience with a database of most of Ajax related articles, resources, tutorials and services from around the world.

Its purpose is to showcase the power of Ajax and to act as a portal to the Ajax development community.


Search


Topics

  • .Net (164)
  • Ajax (83)
  • Ajax Games (10)
  • Articles (95)
  • Bookmarking (35)
  • Calendar (20)
  • Chat (45)
  • ColdFusion (3)
  • CSS (75)
  • Email (23)
  • Facebook (83)
  • Flash (19)
  • Google (54)
  • Html (27)
  • Image (11)
  • International Calls & VOIP (7)
  • Java (54)
  • Javascript (266)
  • jQuery (159)
  • JSON (61)
  • Perl (2)
  • PHP (156)
  • Presentation (19)
  • Python (3)
  • Resources (2)
  • RSS (8)
  • Ruby (31)
  • Storage (4)
  • Toolkits (103)
  • Tutorials (217)
  • UI (11)
  • Utilities (174)
  • Web2.0 (18)
  • XmlHttpRequest (28)
  • YUI (12)

© 2006 www.ajaxlines.com. All Rights Reserved. Powered by IRange