Ajax example

M

meltedown

Peter said:
This implies you *expect* someone here to give it to you.

Yes you are right, that's not want I meant. I wan't asking anyone to
write anything, I really thought an example would already be close at
hand. I'd be happy with "sorry, we don't know of any working examples."
I'd say "thanks for answering my question. "

People here
are *extremely* helpful if you ask politely, you gloss over any
perceived abrasiveness that may simply be a result of quickly chosen
words and you are patient.



The person taking the time to reply probably thought they were being
helpful by pointing you in the right direction and then you could take
the next step of investigation.



In a working example you are probably going to see something clicked
and then text appear on the screen. Where will that get you?

That will then let me see the code in context, which is much less
confusing than trying to get pieces to work. I can never get the pieces
to fit together, and even if I do I still don't know if what I've built
will work in all browsers or if I've just done one step in a greater
application.I'm surprised you don't understand the difference.
You will
then have to look at the code and for Ajax that requires a bit of
theory and probably a tutorial which is what you've bocked at reading.

The tutorials make alot more sense when I can see the code as part of a
working example. Otherwise, its ten times harder to decipher. It seems
like anytime anyone writes a tutorial they skip over the most basic
working examples. They are like you, they don't understand the
importance of basic working examples, in context. They don't understand
what it "gets you".
I could make the example this terse

<script src="ajax.js"></script>
<div onclick="doAjax(this)">do ajax</div>

Yes I would love to see a working example of a simple text change even
if it is this terse. I could then look at the code and understand what
it is doing. Out of context, its all greek.
But when you look in the ajax.js file you will see it is relatively
complicated or maybe it isn't. It depends.

At least it would be in context, which means everything to me.
 
M

meltedown

meltedown said:
I can make a form, but I don't know how to use ajax to update text on a
page. There's lots of examples where the results are put into an alert
box, but I've never seen one where the result appears on the page
without reloading the page.



No it doesn't. It shows the code, but there is no working example.

I figured it out. Basically, all I had to do is replace
alert(request.responseText);

with

document.getElementById('result').innerHTML = request.responseText;

This is basically what I was looking for in my original request:
http://www.reenie.org/test/ajax.htm
This is the simplest working example of Ajax I can conceive of. I'd much
rather look at something like this than some disembodied code in a
tutorial.

Now that I've got a basic ajax application I can study, I'd love to hear
what's wrong with it, if anything, before I start using it and making
it more complicated.
 
R

Randy Webb

meltedown said the following on 1/2/2007 8:29 PM:
I figured it out. Basically, all I had to do is replace
alert(request.responseText);

with

document.getElementById('result').innerHTML = request.responseText;

And I only told you that twice in order to be called a "rude bully". Go
figure.
Now that I've got a basic ajax application I can study, I'd love to hear
what's wrong with it, if anything, before I start using it and making
it more complicated.

Test it. You can get the 3 mainstream browsers for MS Windows for free
(IE, Opera, Mozilla based) and test. If it works in those three then
odds are it will work in most PC based browsers. Then you need a mac
tester and personal experience has taught me that if an ajax page works
in most PC browsers then it will work in most modern mac browsers
(Safari being a possible exception). But then you only need ask for help
with code you made the effort to try to make work instead of asking for
someone to come up with code for you.
 
S

stuart

Hello,

Now I know who posted all the 'where is the example?' comments on my
blog... LOL.

There appears to be a misunderstanding of the term 'example' as used on
the site -> The site which posted the code uses the term 'example' as in
'Code Example', and not as in 'Working Example', most programming
related sites tend to show Code Examples, and not user interface
examples... this is quite normal. Sorry for the confusion this is
causing you.

However, this is a post which includeds both code:
http://www.ajaxtutorial.net/index.php/2006/02/28/ajax-with-php-using-res
ponsexml/
and a 'Working Example' of this:
http://www.ajaxtutorial.net/demo/one.php

This above example shows AJAX (with XML returned)... I'd say it would be
a little more complex than the original URL you mentioned though!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top