Coder Profile - Show off your skills, get a coder profile.
 
 
 
code pin board AJAX Dynamic Content Loader Download Source Code
Author Details Code Information
remy ( Louis Abel )

Pinned 1 Codes
Posted 2 Coding Articles

Send A Message
View Coders Profile
Language JavaScript
Expires Never
Length 1,371 Characters (44 Lines)
Password no password
  1. var _xml = XMLHttpRequest();
  2. onerror = function(_file, _content, _line) { alert(_file + " " + _content + " " + _line); };
  3. if ((!_xml) || (_xml == null)) alert("unable to resolve xml request.");
  4.  
  5. function _loadXML(_file, _div)
  6. {
  7.           document.getElementById(_div).innerHTML = "LOADING CONTENT.";
  8.           _xml.onreadystatechange = function() { _response(_div); };
  9.           _xml.open("GET", _file, true);
  10.           _xml.send(null);
  11. }
  12.  
  13. function _response(_div)
  14. {
  15.           if (_xml.readyState == 4)
  16.           {
  17.                     if (_xml.status == 200) document.getElementById(_div).innerHTML = _xml.responseText;
  18.                     else document.getElementById(_div).innerHTML = "error returned status " + _xml.status;
  19.           }
  20. }
  21.  
  22. index.php:
  23. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  24.           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  25. <html xmlns="http://www.w3.org/1999/xhtml">
  26.           <head>
  27.                     <title></title>
  28.                     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  29.                     <script type="text/javascript" src="navigation.js"></script>
  30.                     <link rel="stylesheet" media="all" href="style.css" type="text/css" />
  31.           </head>
  32.           <body>
  33.                     <?php
  34.                               if ($handle = opendir("."))
  35.                                         while (($file = (readdir($handle))) !== false) print_r("<a href='#' onClick='_loadXML(\"" . $file . "\", \"content\");'>$file</a><br />");
  36.                     ?>
  37.                     <br />
  38.                     output:
  39.                     <div id="content">
  40.                     </div>
  41.           </body>
  42. </html>
code pin board Back To Code Pin Board Post New Code
Please login to post comments.
Page 1 of 1
 
 
Part of the MyPingle Network
Development Blog :: Make A Donation :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents
Version 1.44.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved