LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-29-2007, 07:56 PM   #1
Neko_D
Member
 
Registered: Oct 2006
Distribution: Ubuntu 6.10
Posts: 59

Rep: Reputation: 15
Good Ajax Code Examples


Hey all I have been looking around the net trying to find some good Ajax examples for my senior project. And I cannot for the life of me find what I am looking for.

Basically what I want to do is make a webpage that searches a Database. The page will start off with 5 basic categories, which will be links. What I want to happen is when you click on a link it generates another menu or portion of the website, maybe a div or a table row, with the sub categories of the main categories under it. And you click it again to get the sub categories of the sub categories. If this does not make sense here is a picture

Code:
Winter   Climbing   Camping   Water   Misc
Then the user clicks on Winter and the page adds...
Code:
Winter   Climbing   Camping   Water   Misc
-------------------------------------------
Telemark   Alpine   Snowboard
Then the user clicks Alpine and the page adds...
Code:
Winter   Climbing   Camping   Water   Misc
-------------------------------------------
Telemark   Alpine   Snowboard
-------------------------------------------
Skis   Boots   Poles   Equipent
The clicks boots and the page generates a small form to get the size of the person and then performs a search on it. All of this is done without reloading the page.

In order to generate the various sub menus the webpage hits a database to get the unique categories.

Any help with this would be greatly appreciated.
 
Old 03-30-2007, 01:05 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,426

Rep: Reputation: 100Reputation: 100
if you want to connect to a database you may choose a script language first that gives you this ability like perl, php, python...
You wont need a database to change the variuos navigations according to a clicked topic. 1 of the languages mentioned above will do - or javascript.

In respect of AJAX keep in mind that still a lot of fellows are surfing the web with deactivated javascript. There's no AJAX then.
 
Old 03-30-2007, 11:24 AM   #3
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,499

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
have a look at this AJAX framework, jMaki: https://ajax.dev.java.net/
 
Old 04-09-2007, 03:02 PM   #4
clb
Member
 
Registered: Sep 2004
Location: UK
Distribution: Ubuntu
Posts: 117

Rep: Reputation: 16
All AJAX really means is to pull a page from a server without requiring a refresh of the whole page. Then using JavaScript you can insert the resulting content into a HTML element.

You can have something like:
<div id="categories">Winter Climbing Camping Water Misc</div>
<div id="manufacturers"></div>
<div id="items"></div>
<div id="form"></div>

The items in categories would be links to a JavaScript which would pull the manufacturers details down, and then insert them into the manufacturers div. This would be a series of links generated to link to the JavaScript to fill the items div, which would do the same for the form div.

I think this is the sort of thing you want, if it is you can either search the web for simple AJAX functions or I can post the code I use for things like that. As J-Ray said, if the user has JavaScript disabled then this will not work, and you simply wont get a response. I don't know of anyway of making AJAX based sites degrade well. And as J-Ray said again, you would need to code the pages that you are retrieving in PHP, or a similar language that supports databases.
 
Old 04-09-2007, 03:11 PM   #5
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
Yea, AJAX is nothing more than a set of technologies working together. They are the browser + JavaScript (on the client), and some programming (on the server side). For large sites, the programming on the server side gets its data from a database. The great thing about this model is that all the pieces are (supposedly) completely isolated. The browser doesn't matter, as long as it supports version whatever of JavaScript. This is completely disconnected from the server, which could be running Perl or Python or Ruby or C or Erlang or Scheme or who-cares-whatever. And the database doesn't matter as long as your language of choice can access it. So to do AJAX you really need to know about four different technologies, most likely, and how they inter-relate and communicate with one-another.
 
Old 04-09-2007, 03:17 PM   #6
clb
Member
 
Registered: Sep 2004
Location: UK
Distribution: Ubuntu
Posts: 117

Rep: Reputation: 16
Further to my last post, I see no reason why you couldn't generate nested divs, so you would start with:

<div id="categories">Winter Climbing Camping Water Misc</div>
<div id="stuff"></div>

The categories would then insert the HTML into the 'stuff' div, but would insert:
<div id="manufacturers">Telemark Alpine Snowboard</div>
<div id="items"></div>

Seems a little more complex, and may not be ideal...I don't know, but I can't see why it wouldn't work. I would appreciate some input if I am wrong though.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Cuba and Venezuela - Unlikely Good Examples of Open Source Preference LXer Syndicated Linux News 0 02-21-2007 04:16 PM
Where to find a server-side php code that interacts with Ajax? Basel Programming 2 02-05-2006 05:11 AM
XML Code Examples FLLinux Programming 1 01-17-2006 01:21 AM
Anyone know where I could get some good examples of sendmail files? WorldBuilder Linux - Networking 1 05-14-2003 04:12 AM
Looking for a good list of shell commands with examples jk1 Linux - Newbie 4 06-11-2002 08:09 PM


All times are GMT -5. The time now is 05:09 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration