Ajax list - the source code

December 6th, 2005
previous     next
First, thanks for the interest and the feedback. Glad to hear this thing might be useful. I’ve made some changes and updated the source code. It should now run out of the box. The updates:

  1. Released under LGPL license. Go forth and make use.
  2. Fixed session handling: moved to single call before html headers
  3. Fixed variable declarations for database handling.
  4. Removed references to atWork. Include paths are now relative (sorry about that!)

After getting a number of emails on this thing, I’ve decided to pass along the source code for the list. I’ve written this in PHP with a MySQL database, so included here are the scripts to create the database and tables, the PHP files, the javascript/CSS/html files. There’s one or two images in there too.

note: I’ve experienced releasing code before, and you always get blasted. Are there better ways to do what I’ve done? Almost certainly. All I’m saying is that any criticisms are welcome, but please, keep it constructive!

The files included look something like
theList file structure

To use this:

  1. Unzip everything onto your website
  2. Open the file theList.js and edit line 35. This needs to be the right path based on step 1. If you unzipped into your root directory, it’ll work as-is.
  3. Open the file generalFunctions.php. This file has one PHP function in it. It handles all the database access for the list. Update this as needed. If you’re running mySQL you’ll just have to put in your database name, username and password.
  4. Open the file databaseScripts.txt. This has a bunch of scripts that will create all the necessary tables. It’ll work for mySQL, but may need tweaking elsewhere. Run the script creating the database and tables, then be sure that the username you used in step 3 has full access to the new database.
  5. That should be it, now run the file theListWrapper.php

Any luck?

Comments? Let's hear 'em:

  • #1 : Amber

    Great! I just plugged this in and it’s up and running. I’ll post the address when I put it live.

  • #2 : Ajaxian

    Issue tracking system with source code

    Patrick Ryan had to build an ajaxian issue tracking system for his small team, and it turned out to be nice enough that he decided to share the code with us. :) The platform is PHP/MySql. His three main prorities…

  • #3 : Wyzyrd

    Thanks :)

    I like the app.

    index.php and generalFunctions.php may need a bit of tweaking for sequencing purposes - current release version atempts to set session cookie in index.php AFTER the headers are already sent in generalFunctions.php - not a big deal, but it won’t run “outta da box”
    Thanks

  • #4 : Wyzyrd

    it has been a long day - I meant wrapper, not GF
    my apologies

  • #5 : Patrick Ryan

    Wyzyrd: can you clarify a bit? (and I have an idea this is my lack of knowledge on the topic). I’m setting session in index.php, which is fired up inside of theListWrapper.php. What’s the issue with this? In general I can set session state whenever I want so it should work. (in fact, that is how I’m doing it in the demo version and it seems to go just fine.)

    Clarify? I have a feeling I’ll learn something…

  • #6 : Kenneth

    Sessions can only be set before any information is sent to the browser. As soon as you send any text, whitespace, or anything else to the browser, sessions are no longer available.

    Now, if your PHP set up is tuned for it, or you’re using a wrapper to keep all information in statis until you decide to flush it to the browser, yes, you can set the state whenever you wish.

    I’m assuming that’s what Wyzyrd is talking about.

  • #7 : Greg

    Great work!

    What are the licensing terms? Any chance you could release it LGPL or something like that?

    I’d love to build on this if the license is right.

  • #8 : dotvoid

    Seems to be simple enough but yet really usable. However the PHP code could need some work I guess.

    It did’t work out of the box since it includes files to sit in /agWork/… I don’t know - it might work differently on windows but in unix I don’t want to create agWork under the root directory for web stuff. Use relative paths instead so it is easier to just use the php include_path setting.

    The file generalFunctions have two global variables; $link and $reslt. These must be declared as global in accessDB() and clearDB() for it to work correctly.

    Move the start_session() call. Not everyone have output buffering enabled. It is better to put this statement before any html is included.

    Just three quick things I hade to do to get it to work.

  • #9 : Patrick Ryan

    dotvoid: thanks for the very specific feedback. I’ve updated the zip file and made some notes about at the top of the post.

    It’s this kind of solid feedback that makes sharing work a pleasure!

  • #10 : Sebs

    Different types of javascript errors and warnings: maybe try the strict mode in mozilla to develop and have a lok to the Javascript console
    DOM should be favourized over inner html.
    As far as is see a lot of http req objects are created, why that ? Why not reusing one object. Additionally its a bit of a pollution of the global space.
    Think there is much space for tweaking, looks like you replaced some DOM Helper libraries with php templates, thats a bit of a pain to develop, youll end writing a lot of code for small changes .

    Funny example anyways, good job because it has flow to work with.

  • #11 : Patrick Ryan

    Sebs: The script warnings are strange. I built this thing with ffx in strict mode and I don’t get any errors at all. What are you seeing?

    As for your other thoughts, I noted most of them in comments within the code.

    The innerHTML move was entirely on purpose. Altough innerHTML isn’t in the W3C spec, I prefer it (and I wrote a long post on this, but my database crashed and I lost it… will be coming soon). The mulitple https are addressed in a comment in the .js file. Overall I think this framework is much easier to make changes with less code.

    But a lot of this stuff is personal preference…

  • #12 : Werner blogt » Blog Archive » links for 2005-12-09

    [...] Agave Group » Blog Archive » Ajax list - the source code Issue tracking in AJAX (tags: AJAX tracking) [...]

  • #13 : Miguel Benevides

    Nice code, was going to “tweak it” and build on it for testing… but i can’t seem to get the Sessions to work… even in the online demo (noticed when we add a note…$_SESSION['theListUser'] is empty.

    Keep up the good work

  • #14 : Jason Kee

    Miguel, I’ve got the session to work by setting session.auto_start = 1 in php.ini. Hope that helps!

  • #15 : Yet Another Blog from Luar » Ajax Framework and Library

    [...] Ajax list: keep track of the work our little development team is working on. [...]

  • #16 : content article

    Excellent discussion.

  • #17 : picture of zoroastrianism

    Amazing post; keep it up!

  • #18 : jmenning

    This looks like a great little app - and perfect for what I need! My PHP is very rusty and was never strong to begin with, so I was looking for something simple.

    I know it’s been a while since this was posted, but I’ve got a little problem and I was hoping that someone could help me out.

    I’m testing it here:
    http://www.jmenning.com/theList/theListWrapper.php#

    I’m getting an error when I try to add a note to an item. To get this error, I display a list item, type in some comment in the note field, and click the “save note” link:

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/blue/public_html/theList/ajaxActions/saveNote.php on line 34

    The section that seems to be breaking in saveNote.php is:

    $result = accessDB($sql);
    if($row=mysql_fetch_array($result)){
    $userName=$row['user_name'];

    The error shows up whether the user is logged in or not.

    I have not changed saveNote.php. Any idea why this might be causing a problem?

  • #19 : jmenning

    Minor note:
    Using this out of the box, in the main list, when viewing in IE, the create date gets scrunched over next to the description. The fix is simple: change the theList.css file:

    In the #appTrack #listItems .shortDescription style, replace:

    min-width: 400px;
    max-width: 400px;

    with:

    width: 400px;

    The columns then align properly in IE and Firefox.

  • #20 : andy

    great example! big thanks!

  • #21 : Simply-Basic.com » Awesome PHP/Ajax To-Do List

    [...] While surfing the internet today, I came across something called “The List“. Simply put, it’s a to-do list written in PHP with a MySQL database. It’s actually quite remarkable. It would be the perfect to-do list for a web-based group working on software development, but could be adapted to suite almost any need. [...]

  • #22 : Dretio

    Does anyone have a solution for the problem jmenning had with the saveNote.php?

    I can’t get rid of this error :

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/blue/public_html/theList/ajaxActions/saveNote.php on line 34

    Many thx!

Leave a Reply

name (required)

email (will not be published) (required)

website

comment