AJAX - jQuery Dynamic Content Loading

Rate this:
By boomroker (Contact - View My Woyano)
Published Thu 06 Sep 2007, 2804 Views, 2 Comments

Here is something that I really like.

Dynamic HTML content loading... very easy to implement in a normal static website and its brilliant if you want to load something from
text files, xml's, pictures, even other websites!

Start by downloading the jQuery Content Loading ZIP files. This contains jQuery 1.2, index.html and rpc.php

NOTE: You will need a webserver running php to use this. WAY BEYOND the scope of this article

Once you have the files unzipped in your webservers document root you will have something that looks like the example from the site.

What you now obviously want to do is spice it up with your own CSS and have something really dynamic load when you click the links...

Open up rpc.php in VI or what ever you use to program and edit (Notepad, Dreamweaver etc).

The green code is what I added

<?php

    $cOption = $_GET['o'];
    $dynamic_source = "";
     
    switch($cOption) {
        case 1:

$dynamic_url = "your/target/file.whatever";
        $fp = fopen($dynamic_url, "r") or die("The Information couldn't be displayed!");
          while(! feof($fp))
  {
     $dynamic_source = $dynamic_source . fgets($fp, 1024);
  } print $dynamic_source;
           
            break;

default:
            echo 'Whoops, I havent had time to implement that yet...: <i>'.$cOption.'</i>';
    }

?>

You can add as many cases as you like... just remember to add a button to it.

Hope t
his helps someone someday...
It beats having to put static code in the case statement as in the example... I seriously dont know why they always use static examples for dynamic code...

Someday when I have time I'll play around and get a busy indicator built in... Someday (tm)


This Item
Category: Knowledge, How to's, Computers
Tags: ajax,jquery,css,html
Contributor
boomroker
Share it
Link to this item:
Bookmark this item: RSS Feed

People who liked this item

    2 Comments

  1.  
    JV ~ 12 months ago
    1 vote thumbs up thumbs down
    Ah yes, we even use jquery on woyano :)
    [ reply ]
    1.  
      boomroker ~ 12 months ago
      0 votes thumbs up thumbs down
      Did you write your own plugins etc?

      My programming sucks.. so if its not on the web... I wont be making it :D
      [ reply ]
    2.  
      22 votes thumbs up thumbs down
      This is my two cents...

         
      Hey you know AdGuy always gets the last word! ;)

    Please Login to Add Your Comment   ..or..  

    Replying to comment by