Jump to content

Recommended Posts

I need to understand why one needs or wants to use Ajax.

I do understand that moving a large amount of data across a network(and the internet is a network) when only one or two pieces of data are needed is a waste. I am assuming that when a user clicks a button on a form based web page the whole form is moved.

 

Link to comment
https://forums.phpfreaks.com/topic/115560-understanding-why-ajax/
Share on other sites

Ajax is simply a way to send and recieve data to and from the server asynchronously. That's it. I think a lot of people completely misunderstand what Ajax is. The bottom line is, ajax can be very useful for some applications but your site should still be 100% functional if javascript is disable. This is true anytime you use ajax.

I understand what maexus had to say and if one must allow for users who have javascript disallowed, why use it at all?

I am also confused as to why it would "allows for websites to behave more like traditional desktop applications"

I can see the advantage on large web pages(I think) but if one has to allow for user with javascript switched off, then why use it at all?

Visualize a ladder. The higher you climb on the ladder, the richer the user experience. On the bottom of the ladder you have HTML, you have the raw unformatted content. If you climb a little higher then you will reach CSS and your content will now be formatted and look really nice. Climb even higher and you will reach Javascript will define behavior for your content.

 

That is how those three things are often separated into layers. The first one being the content layer, the second being the presentation layer and the third one being the behavioral layer.

 

If you just have the content layer then it will work for the user; s/he can read the content. If you add the second layer then you will style it and the consequently get a richer user experience. Add the last layer and the user will be able to interact with the content (because you added behavior to it) and s/he will get an even richer experience. In your instance this behavior would be whatever AJAX technique you are looking to implement.

 

The reason why you would code if for both Javascript on and off is that you cannot rely on having Javascript on. Some might use a browser that does not support it (e.g. lynx) or they may deliberately turn it off. You shouldn't lock those users out so you should make the page work for them as well. The result is just that they will not benefit from the last layer.

 

As an example of Javascript's richness, try to use Gmail in the default mode (i.e. Javascript) and then in basic mode (HTML-only). I'm sure you will find the Javascript enabled one much better.

I am also confused as to why it would "allows for websites to behave more like traditional desktop applications

 

When you click on File -> Open in an application, does the entire application shut down, reload, and display an open file dialog?  That's what a non-ajax site has to do.

 

You don't always have to make your application work without JavaScript.  Some AJAX applications are meant to be run internally on an intranet where you control the environment and a requirement of the application can be that JavaScript has to be enabled.

Being able to build a website that acts like a standard application is a good things.  If you are building an application that is mainly pulling and sending data from a database(or other data source), building an interface in HTML and logical code is a server side scripting language like php is a lot easier than building everything in a language like C++.

 

As far as a general access website i do believe it is good practice to make your site work with javascript disabled(even tho about %5 seem to be disabled according to w3schools browser stats) even tho it is not a huge requirement but when build web applications(like a project management system) the use of ajax can make the application so much easier to use.

I'd also like to point out that, because you're not completely reloading the page, AJAX does cut down on bandwidth, both for the server and the user, by a fraction.

 

JavaScript and AJAX are also very useful for making things flow more easily. Think of Google Maps. Can you imagine how tedious that would be if every time you moved the map with your mouse, you had to reload the page?

 

EDIT: On the disabled thing, I have firefox, but I also use NoScripts. NoScripts, by default, disables javaScript for several security/general reasons. It's always very annoying for me when I have to go to 'temporarily allow' just because someone couldn't be bothered to design their site in a compatible way.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.