Ajax vs. jQuery + PHP Experience

thomys.eventos13

New Member
Messages
4
Reaction score
0
Points
0
Hi there,

I've been looking about Ajax and jQuery, and many people says like Ajax is too limited while jQuery releases a new plugin each week… Perhaps Ajax may look professional but jQuery is really extended. Also with PHP a really easy and useful language the fan of possibilites gets even wider…

So… have you experienced the creation of high quality pages, with astonishing design and extremely cool programming that you can tell me here?

I'm not new but nor I'm very expert with this, and I'd like to learn how to take these languages to the maximum expression.

I thank your help in advantage.

Regards. :)
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
jQuery, mootools, Dojo, etc are Javascript frameworks that all include AJAX capabilities. There is no "AJAX" framework or programming language. It is just a bunch of techniques.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
descalzo's answer is right, but (given your question) it may be at too high a level for you to make use of it.

Ajax is the magic that lets your web page send information to and get information from the server without reloading the page. The name stands for "Asynchronous JavaScript And XML", but it's really a misnomer -- the communication is usually asynchronous*, but it doesn't have to be (there are times when a synchronous† call makes more sense) and XML isn't used very much anymore. "Ajax" was a name given in 2005 by Jesse James Garret to a technology that already existed; Microsoft had been using it since IE5 using an ActiveX object and simply called it "Dynamic HTML", Mozilla had introduced a "pure JavaScript" version in its browsers by then, and Google really kicked the party off by using the new technology in Gmail. The name "Dynamic HTML" wasn't going to fly – we were already using that name for anything that used JavaScript to change the web page – so we quickly adopted the term "Ajax" even though the "X" part of it was often a bit of an exaggeration.

"Ajax" is anything that uses the XMLHttpRequest object to make a request from the server. That lets you load and reload parts of the web page without having to reload the whole page. It is only limited in the following ways:
1) the browser needs to support the XMLHttpRequest object, either as a native JavaScript object or as an ActiveX control (IE 5 to 6);
2) JavaScript must be enabled in the browser; and[/li]
3) the browser has to make requests from the server – the server can't send anything to the browser except in response to a request.

The server part of the equation doesn't really matter, as long as it can respond to user requests. Usually, you want to send different information to different users at different times, so you'll want a way to generate dynamic content. PHP can do that, but so can ASP/ASPX, JSP, JSF, "pure" Java, Python/Django, Perl, Ruby/RoR, ColdFusion, NodeJS, Apache CouchDB, Lotus Domino,... You get the idea. PHP has the widest hosting support, and it's the only dynamic option you have here on a Free Hosting plan, so it's the one you'll probably want to use.

The remaining problems with "straight" Ajax (and "straight" JavaScript) are that no two browsers ever do things in quite the same way, and that you have to reinvent the wheel, so to speak, in order to do what other people are doing on their pages. That's where libraries and frameworks come in. Of the ones that descalzo listed, there are really only two that have any serious currency: Dojo and jQuery. (I liked MooTools, but it has sort of fallen by the wayside.) Dojo is massive, and is oriented towards serious business applications. It is great for building web business applications that look and act a lot like desktop business applications, and it is integrated into several business-oriented platforms (particularly those from IBM/Lotus). But Dojo will never take off its tie, grab a beer or spark a spliff and relax and play -- it's all business, all of the time.

jQuery has become something of a standard over the past couple of years. That's mostly because it's hosted on Google's CDN, so even though it's a fairly big chunk of JavaScript, even in the minified form, it is probably something your users will already have in their browser cache so you won't be forcing a large download. What jQuery does, mostly, is to insulate you from all of the little differences between browsers. You tell jQuery what you want to do, and let jQuery worry about how IE, Chrome, Safari, Firefox, Opera, Konqueror or whatever actually does it. Without something like jQuery, you need to worry about all of those differences, like "what does XMLHttpRequest mean in this browser", "does this browser support getting elements by class name" and so on.

jQuery also has some common "special effects" built into the main library, so you don't need to re-invent the wheel. The plugins mostly add to the repertoire of effects, though some are designed to make field widgets (like calendar controls and so forth) available. You don't need to use any jQuery plugin you don't need to use, and you can continue to use whatever version of jQuery your code was written for – you aren't jumping on a continuous-upgrade treadmill.

So it's not a choice between Ajax and jQuery+PHP, really. Any Ajax you use is probably going to mean using PHP on the server to generate the content, and unless what you are doing is very simple and straightforward, you're going to save a lot of time and potential bugs if you use a library like jQuery to handle browser differences and deficiencies.

___________
* asynchronous: You make a request from the server, and tell the browser what to do with the response. In the meantime, the user can continue interacting with the page, and you can make additional background requests.

synchronous: You make a request from the server, and the browser waits for a response. Nothing else can happen until the response is received. Use synchronous requests only when the response is critical to the rest of the application.
 
Last edited:
Top