This is a discussion on "Basic question re: ajax implementation" within the JavaScript Forum section. This forum, and the thread "Basic question re: ajax implementation are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Basic question re: ajax implementation
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Basic question re: ajax implementation
I'm thinking about implementing ajax for the first time. I would be using it to allow a user to login without leaving the message board page (and subsequently to update the page with "post" and "reply" links that aren't displayed for users that aren't logged in.)
My question is: What about users that have javascript disabled? I'd still need a separate means (using php, in my case) for such users to login, won't I? If I'm correct in this assumption, why should I put the time and effort into writing both branches of code? (Or will the ajax page simply reuse the code from the login.php page?) |
|
|
|
|||
|
Re: Basic question re: ajax implementation
I can't offer you any help on your post simply because I just started reading a book on Ajax, which by the way looks AWESOME!!!
I was really intrigued by what Ajax does for web apps after briefing over a book in the store on it. Photobucket.com uses Ajax to allow users to change the "title" of their image, the page doesn't refresh (love that feature of Ajax) and the title updates right in front of your eyes. Its amazing. I look forward to learning how to use Ajax and implementing it in my web apps Now as for your "javascript" portion of the question...that's a good point with regards to "what if users have it disabled in their browsers"...why anyone would disable javascript (which is so widely used on just about every web page) is beyond me. I'd be interested to know why they would though... I also see some tedious work involved if you have to create 2 separate sources of code for accomplishing the same task. But then again, that can sometimes be the case when programming for the web. Just like with javascript and testing to see what web browser the user is surfing with. *Come on guys! Help Donny Bahama out...I'm interested to see what the "answer" is too |
|
||||
|
Re: Basic question re: ajax implementation
I have a very simple answer for you matey: jQuery.
I learnt Ajax the hard way. Long winded trial and error, sleepless nights, lots and lots of coffee. But I guarantee you will find it much easier and learn much quicker with jQuery. Now let me address your actual question: Quote:
1. Greatly reduces the load on your server... 2. Improves visitor experience - mostly because it's faster to submit something and get the response via ajax than it is to submit and reload the entire page. One argument in favour of Ajax is that around 99% of users have Javascript enabled. It's almost like making websites for browsers without any CSS support. It's just not gonna happen, you can use and abuse CSS as much as you like. HOWEVER, it's easier to do things properly then having to deal with problem later on, so in that sense, yes, you must always make sure your application works smoothly with or without javascript. One way to achieve this effect is to have your serve-side scripts identify the ajax call and return an ajax specific response, telling your javascript how to update the page (display error messages, confirmations, etc). I do exactly that on all my websites. If Ajax is disabled, everything works exactly the same, with the same error messages/confirmations in the same places with the same colours, etc... Consider this page structure: <? Do some php stuff: validation, db calls, etc ?> <html> <? Show page output ?> All you need to do is add a little bit of code to achieve the following: <? Do some php stuff: validation, db calls, etc ?> <? If ajax call, send some instructions to update DOM and STOP HERE ?> <html> <? Show page output ?> If you want to see this in action, try: 1. Get Firefox if you haven't already 2. Get Firebug and Web-developer Toolbar if you haven't already (these 2 will let you monitor ajax call so you see what's going on) 3. go to one of my sites (try http://www.123cleaners.com/), 4. go to the contact page and play around with it (just fill everything in with the word 'test' so they think it's me messing about and ignore the emails) 5. Use the Web-Developer toolbar to disable Javascript and try it that way... PS.: I'm not saying you should use the same methods I used, but it may help get you started.
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Last edited by spinal007; Apr 12th, 2007 at 20:17. |
|
|||
|
Re: Basic question re: ajax implementation
Quote:
That is why I will sometimes avoid javascript (like the plague) - depending on my audience. My current project, for example, is a site for a 50th high school reunion. And this particular class of 1957 is from a small, blue collar town in the midwest. Less than half of the people who have been contacted/confirmed have e-mail. (Obviously, they are not my target audience as they probably don't even own a computer.) Of the rest, only a handful are using broadband. And when I asked for current photos (to go on their classmate profile page next to their yearbook photo), less than a dozen were able to e-mail me a digital photo! (Please don't infer any disrespect on my part. These people are awesome. Doing their site has been totally fun and rewarding - if challenging. It is what it is. My grandma won't touch a computer. Period. I won't do needlepoint or play an organ in church on Sundays. Different strokes...) I think too many web developers make assumptions about the proficiency level of their audience. It's one thing to say that someone has javascript enabled - quite a different matter to think they'll know what the heck "trying to run active content" means - and allow it to run. |
|
|||
|
Re: Basic question re: ajax implementation
Looks like great stuff, there, Diego. Thanks so much for the helpful links - I'm sure I'll get great use out of them. But I think I've concluded that ajax just isn't right for my current project, so I'll put it on a back burner for now and check all that out a bit later.
|
|
|||
|
Re: Basic question re: ajax implementation
An important point also, regarding a fallback for javascrippt, is that in many businesses and organisations it is company policy to have javascript switched off. Which depending on your site/service could be an important issue, although I am aware that for the most part this would not be a major concern. Despite this, as dreadful as my javascript skills are, what little I do implement I make sure has a fallback. But that is down my design principles rather than anything rational.
Ajax is spiffy though, I've got to admit that. Pete. |
|
||||
|
Re: Basic question re: ajax implementation
Quote:
And regarding you earlier post... Quote:
Thank God "web 2.0" is all about following web standards and many developers are keen to adhere or we'd have mayhem.
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
|
![]() |
| Tags |
| ajax, javascript disabled, usability |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ajax implementation | alexgeek | Website Planning | 10 | Oct 14th, 2007 12:47 |
| Basic JS question | klonopin | JavaScript Forum | 1 | Mar 15th, 2007 00:31 |
| Very basic Links question | rubyfruit | Web Page Design | 4 | Sep 5th, 2006 23:17 |
| Probably very basic CSS question | JonRouston | Web Page Design | 3 | May 18th, 2006 12:08 |
| Basic XML question | fogofogo | Other Programming Languages | 2 | Nov 23rd, 2005 08:58 |