ajax, javascript, php, frameworks, libraries, YUI, jQuery,

fuzzybabybunny

Moderator<br>Digital & Video Cameras
Moderator
Jan 2, 2006
10,455
35
91
So I stumbled upon javascript libraries and frameworks. I was going through the source of some site and I wondered what this little yuiloader-min.js file was. Googled it, looking at YUI, and though "WTF IS THIS SH*T?!" Here I am, sitting in a cave, thinking I had to jack scripts from other people to make my own, and here's a library?

So, uh, WTF is it?

It looks immensely useful - lots of premade scripts all in one place for the taking, but I'm confused on how it all ties together, or how it even works.

1. Are frameworks and libraries the same?
2. Can you use different libraries on the same website at once, like combine their strengths?
3. I'm still fuzzy on what exactly AJAX is. Something about widgets? Sounds a lot like more scripts I can use.
4. MySQL is in here somewhere, right?
5. Like, what's going on?
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
1. depends on who you talk to i think
2. typically yes, assuming the two libraries don't have conflicting objects or functions or keywords.
3. ajax is a no longer completely accurate acronym. basically, its using javascript to make server side calls and update a page without the client reloading the page. its DHTML with additional server side processing.
4. database.
5. ahh not much. about to head to bed. been a long day. wife and i bought a bunch of flowers and plants and planted them in a bunch of old pots. i also did 5 loads of laundry and watched Animal House.
 

Snapster

Diamond Member
Oct 14, 2001
3,916
0
0
Originally posted by: fuzzybabybunny
So I stumbled upon javascript libraries and frameworks. I was going through the source of some site and I wondered what this little yuiloader-min.js file was. Googled it, looking at YUI, and though "WTF IS THIS SH*T?!" Here I am, sitting in a cave, thinking I had to jack scripts from other people to make my own, and here's a library?

So, uh, WTF is it?

It looks immensely useful - lots of premade scripts all in one place for the taking, but I'm confused on how it all ties together, or how it even works.

1. Are frameworks and libraries the same?
2. Can you use different libraries on the same website at once, like combine their strengths?
3. I'm still fuzzy on what exactly AJAX is. Something about widgets? Sounds a lot like more scripts I can use.
4. MySQL is in here somewhere, right?
5. Like, what's going on?

1. Not really, they each have their own idea's and implementations. Some of them borrow from each other.

2. Depends on the library although this is getting better. Quite a few of them just break each other because they use similar function names, or use the $ identifier.

3. Ajax is basically asynchronous calls to the webserver without having to reload the page, you send a request get a response and deal with it how you wish (such as update a page element).

4. Most of the library pages use a MySql db back end in example code, but it's not tied to the libraries themselves (as they are client side JavaScript).

5. Enhancement of web pages/interaction with tried and tested code. Small libraries gets a thumbs up from me, however bloated get a thumbs down. :)

NB: It's worth understanding the basics of JavaScript first before you use libraries. If the library breaks or is not used correctly you'd be even less informed having skipped learning how JavaScript works. :)
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,836
4,816
75
Let me focus on points 3 and 4. AJAX is an acronym:

Asynchronous: means that what happens with AJAX doesn't happen at the time of loading a new page. It doesn't happen because a page loads, and it doesn't cause a full new page to load, either.
Javascript: in this case, Javascript that manipulates the page. This involves DOM manipulation, either using InnerHTML, or by adding or manipulating nodes.
And
XML: This doesn't specifically refer to an XML document, though they're commonly used. Instead, it refers to the Javascript command "XMLHttpRequest", which is the basic method to get data from a web server (or web service) or even send data back! You can get XML data that way, or you can get other things, like, say, part of an HTML page. There should be better wrappers for XMLHttpRequest in libraries; though I haven't used libraries that much. (It's on my todo list.)

4. A database is something you access (directly) with server-side code. This can be PHP, ASP, even CGI or Ruby on Rails. The way a database is connected with Javascript is with a "web service". A web service works like a server-side scripted page, either sending out data from a database, or receiving it with GET or POST. The difference is that a web service is usually intended more for computers to read than for humans. So the Javascript uses an XMLHttpRequest to GET data from a web service (which gets its data from a database), manipulates it, and displays it in the DOM. And the other way around, a person can enter data that Javascript parses and sends via an XMLHttpRequest GET or POST to a web service, which stores it in the database.
 

NiKeFiDO

Diamond Member
May 21, 2004
3,901
1
76
I'm going to go out of order here:

As you might have guessed, AJAX is the most confusing buzzword here because it is used to mean a few things.
A) The most technical, AJAX was first coined to describe a somewhat specific use of XmlHttpRequest object (Javascript) - This allows you to make Asynchronous requests - in other words, calling a web page as a "background process" when you are on another page. Many times the page request results purely in XML or some other way (JSON encoding for instance) which is easily used to grab some information from the page request.

B) The most "buzzwordy" usage of AJAX is to describe any kind of effect you can get on a site using Javascript - Such as tabs, image sliders, galleries (google "lightbox"), anything that looks like it was made in Flash but wasn't.

Some of the most popular Javascript frameworks (Jquery, Mootools/Scriptaculous) do indeed interfere with each other because they both use the "$" as an object identifier. I know Jquery has a "noconflict" mode which makes you use "jQuery" instead of "$" and so in short, yes, you can use libraries in combinations if you are willing to do a little reading up on the topic.


Think of frameworks as having libraries of code, rather than "libraries" and "frameworks" being the same. Frameworks are a cohesive collection of code libraries.

MySQL (or SQL or file storage, or any time of data storage / persistence) are all just ways to save information for you to call up later. For instance, an ajax call might take some user input and save it to a database and then update a part of a webpage with that new information - all without doing a reload of the web page (but it does at least 1 page request / data transfer in the "background").

Hope this helps make sense of it all...
 

Woosta

Platinum Member
Mar 23, 2008
2,978
0
71
Originally posted by: Ken g6
This involves DOM manipulation, either using InnerHTML, or by adding or manipulating nodes.

It's worth noting that innerHTML isn't a standard of the W3 DOM API and started out proprietary but is completely fully supported nowadays through various user agents.

Originally posted by: Ken g6
And
XML: This doesn't specifically refer to an XML document, though they're commonly used. Instead, it refers to the Javascript command "XMLHttpRequest", which is the basic method to get data from a web server (or web service) or even send data back!

More technically XMLHttpRequest is the method of the window object, only provided in the context of a user agent and is not a full fledged native ECMAScript method.