Ajax example

M

meltedown

This is supposed ot be an example:

http://www.ajaxtutorial.net/index.php/2006/11/30/simple-ajax-using-prototype-part-2/

It says :

This example is probably the simplest example you will ever find.
We are going to use the prototype feature ‘ajax.Updater’ (see part one
for more details on prototype).

ajax.Updater allows you to specify an element ID and script URL - and
whatever the script URL prints will appear in your element ID. Simple as
that.

I would love to see such an example. Unfortunately, there is no example
on that page.

Does anyone know where there is such an example ?
 
M

meltedown

Dag said:
Eh?

In the middle of the page at the link above?
Clearly marked with a green "Examples" heading?


I see where it says "Examples" but there is no example, only code snippets.
The example should look like this : a form with a text field. When you
add text to the field, the text appears on the page.
 
D

Dag Sunde

meltedown said:
I see where it says "Examples" but there is no example, only code
snippets. The example should look like this : a form with a text
field. When you add text to the field, the text appears on the page.

You're kidding, right?

it isn't a tutorial on how to make a form post a textfield to
some serverside script, neither a tutorial on how to make serverside
script that returns some text bak to you.

You surely know how to do the two things above?

It show you an example how to use that particular function
to update an element with the response of a given serverside script.
 
M

meltedown

Dag said:
You're kidding, right?

it isn't a tutorial on how to make a form post a textfield to
some serverside script, neither a tutorial on how to make serverside
script that returns some text bak to you.

You surely know how to do the two things above?

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.

It show you an example how to use that particular function
to update an element with the response of a given serverside script.

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

Randy Webb

meltedown said the following on 1/2/2007 5:50 AM:
Dag Sunde wrote:


I can make a form, but I don't know how to use ajax to update text on a
page.

You don't use "ajax" to update the page. You use ajax to retrieve the
data from the server. Then, you use that response and update the page.
Check the group FAQ for DynWrite (see my signature) for a function that
will update the 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.

Instead of alert('something') you do
document.getElementById('someID').innerHTML = 'something';, or, you
DynWrite it.
No it doesn't. It shows the code, but there is no working example.


If you can't take code from the manual and make it work, you need a
different approach.
 
M

meltedown

Randy said:
meltedown said the following on 1/2/2007 5:50 AM:

You don't use "ajax" to update the page. You use ajax to retrieve the
data from the server. Then, you use that response and update the page.
Check the group FAQ for DynWrite (see my signature) for a function that
will update the page.


Instead of alert('something') you do
document.getElementById('someID').innerHTML = 'something';, or, you
DynWrite it.



If you can't take code from the manual and make it work, you need a
different approach.
I don't understand why I can't just ask for a working example without
all the snarky responses. If there is no working example of what I'm
asking for, fine, but that's what I'm looking for.
 
R

Randy Webb

meltedown said the following on 1/2/2007 6:08 AM:
I don't understand why I can't just ask for a working example without
all the snarky responses. If there is no working example of what I'm
asking for, fine, but that's what I'm looking for.

First, a "complete working example" would have to include the server
side code as well, or, use a static file.
Second, you didn't get a "snarky" response, you got an honest one.
Third, I doubt - very seriously - that you will find very many "complete
working examples" on the web of a complete ajax application.
 
M

meltedown

Randy said:
meltedown said the following on 1/2/2007 6:08 AM:

First, a "complete working example" would have to include the server
side code as well, or, use a static file.
Second, you didn't get a "snarky" response, you got an honest one.
Third, I doubt - very seriously - that you will find very many "complete
working examples" on the web of a complete ajax application.

Why not ? As I said before, there's lots of complete working examples of
complete ajax applications where the results are put into an alert box.
Here's a bunch of assorted complete working examples of complete ajax
applications right here, but it doesn't include the most obviously
needed example, that of a simple display of text on the web page.

http://wiki.script.aculo.us/scriptaculous/show/Demos

You are not making any sense to me.
 
D

Dag Sunde

meltedown said:
Randy Webb wrote:


Why not ? As I said before, there's lots of complete working examples
of complete ajax applications where the results are put into an alert
box. Here's a bunch of assorted complete working examples of complete
ajax applications right here, but it doesn't include the most
obviously needed example, that of a simple display of text on the web
page.
http://wiki.script.aculo.us/scriptaculous/show/Demos

You are not making any sense to me.

The feeling is mutual... :)

Oh, for God's sake... here you go:
(Completely untested, from the top of my head sample)

server.asp:
<%@ Language=VBScript %>
<%Response.Buffer = True%>
<%
Response.Buffer = True
Dim s

Response.ContentType ="text/html"
Response.CacheControl = "Private"
Response.AddHeader "Cache-Control", "no-cache"

If Not isempty(Request.Form("someString")) Then
s = "<h1>" & Request.Form("someString") & "</h1>"
Else
s = "<h1>you didn't say anything</h1>"
End If
Response.Write s
Response.End()
%>

test.html:
<html
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TestSomeAjaxThingy</title>
<script src="/scripts/prototype.js" type="text/javascript"></script>


<script type="text/javascript">
function sendIt() {
}
</script>
</head>

<body>
<input type="text" id="someString" name="someString" value="" /><br />
<input type="button"
id="btnSend"
name="btnSend"
value="Send"
onclick="new Ajax.Updater('results', 'server.asp',
{asynchronous:true});"/>
<br />
<div id="results">It should appear here</div>
</body>
</html>


Note: I've never used prototype.js in my life, but the above is the
principle.
 
M

meltedown

Dag said:
The feeling is mutual... :)

Oh, for God's sake... here you go:
(Completely untested, from the top of my head sample)

server.asp:
<%@ Language=VBScript %>
<%Response.Buffer = True%>
<%
Response.Buffer = True
Dim s

Response.ContentType ="text/html"
Response.CacheControl = "Private"
Response.AddHeader "Cache-Control", "no-cache"

If Not isempty(Request.Form("someString")) Then
s = "<h1>" & Request.Form("someString") & "</h1>"
Else
s = "<h1>you didn't say anything</h1>"
End If
Response.Write s
Response.End()
%>

test.html:
<html
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TestSomeAjaxThingy</title>
<script src="/scripts/prototype.js" type="text/javascript"></script>


<script type="text/javascript">
function sendIt() {
}
</script>
</head>

<body>
<input type="text" id="someString" name="someString" value="" /><br />
<input type="button"
id="btnSend"
name="btnSend"
value="Send"
onclick="new Ajax.Updater('results', 'server.asp',
{asynchronous:true});"/>
<br />
<div id="results">It should appear here</div>
</body>
</html>


Note: I've never used prototype.js in my life, but the above is the
principle.
Oh for Gods sake yourself. Do you know the difference between code and a
working example ?
 
D

Dag Sunde

meltedown said:
Dag Sunde wrote:

Oh for Gods sake yourself. Do you know the difference between code
and a working example ?

You're welcome.

Always nice to help!

:-D
 
M

meltedown

David said:
meltedown said:
And that's what you get when you feed a troll.

D.
I didn't do anything trollish at all. I simply asked for a simple
working example of an Ajax script that would change text on a page and I
haven't seen one yet. I have seen a bunch of answers from people who
don't seem to understand the request, or are pretenting they don't
understand. I have really really hard time understanding something like
the code above. I can look at it for hours and hours and it makes no
sense. Its Greek. And I have really hard time getting it to work. But If
I can see it in a working, example, after about 5 minutes, it is much
more clear. So my question is not ridiculous. What is ridiculous is the
idea that I have written anything that is remotely wrong or confusing to
any honest person.

You guys are bunch of rude bullies.
 
R

Randy Webb

meltedown said the following on 1/2/2007 4:08 PM:
I didn't do anything trollish at all.

You come ask for an example, you get more of an example than most people
are willing to bother with, and then you complain about that?
I simply asked for a simple working example of an Ajax script that
would change text on a page and I haven't seen one yet. I have seen
a bunch of answers from people who don't seem to understand the
request, or are pretenting they don't understand.

I explained to you, in this thread, that if you look in this groups FAQ
(which is in my signature) and search for "DynWrite" that you would find
an entry that shows how to make it modify the page itself instead of
using an alert.

The steps for an "ajax request" go, in plain English, like this:

1) User says "Give me that data".
2) Browser requests that data from the server.
3) Server sends that data to the browser.
4) Browser displays that data.
5) User gets the data.

The only step in that list that you have wanted changed was step 4 which
is how the browser displays that data. The examples you have posted
URL's to use an alert to display it.

Yet, you want someone to write all 5 steps, from scratch, just for you
and you complain when they won't. This isn't a help desk, its a
discussion group.
You guys are bunch of rude bullies.

If not writing a full blown app just for you makes me a bully, then I
will remain a bully until I get paid for writing that app for you.

<URL: http://www.ajaxtoolbox.com/>
 
D

Dag Sunde

meltedown said:
David Gillen wrote:
I didn't do anything trollish at all. I simply asked for a simple
working example of an Ajax script that would change text on a page
and I haven't seen one yet. I have seen a bunch of answers from
people who don't seem to understand the request, or are pretenting
they don't understand. I have really really hard time understanding
something like the code above. I can look at it for hours and hours
and it makes no sense. Its Greek. And I have really hard time getting
it to work. But If I can see it in a working, example, after about 5
minutes, it is much more clear. So my question is not ridiculous.
What is ridiculous is the idea that I have written anything that is
remotely wrong or confusing to any honest person.

You guys are bunch of rude bullies.

No, we're not!

The sample I actually took time to sit down and write specifically
for you is what I thought you need (and meant).

I had no idea that that you needed a ready-made web-site with
a button to click on.

I believed you needed the source-code for an working example
so you could set it up on your own machine to experiment with,
and that was *excactly* what I gave you:
The content of 2 files. server.asp and test.html to put somewhere
on your IIS server. Then you could point your browser to
http://yourserver/test.html, and tested/played with the *working
example*

If the code was greek to you, you could have posted further questions
here, to get specific points clarified.

If you don't even know how to set up those two files I posted on your
own webserver, you could have said: "Wow! Thanks! But how do I use them?
Can you please take the time to help me set it up, so it runs on my
computer?"

Believe me, everyone that have replied to you have really tried
to help you, despite your sometimes "snotty", whining remarks.
 
P

Peter Michaux

meltedown said:
I didn't do anything trollish at all. I simply asked for a simple
working example of an Ajax script that would change text on a page and I
haven't seen one yet.

This implies you *expect* someone here to give it to you. 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.

I have seen a bunch of answers from people who
don't seem to understand the request, or are pretenting they don't
understand.

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.

I have really really hard time understanding something like
the code above. I can look at it for hours and hours and it makes no
sense. Its Greek. And I have really hard time getting it to work. But If
I can see it in a working, example, after about 5 minutes, it is much
more clear.

In a working example you are probably going to see something clicked
and then text appear on the screen. Where will that get you? 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.

I could make the example this terse

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

But when you look in the ajax.js file you will see it is relatively
complicated or maybe it isn't. It depends. You need to spend the time
to read the tutorials . . .

On the group faq look for books and get Flanagan's fifth edition and
read the chapter on Ajax. Then realize that there are bugs in that
chapter and look at the errata on the O'Reilly site. Then realize that
not all the bugs have been posted there yet and that there are issues
with IE memory leaks and IE/Firefox XHR abort() calls.

<URL: http://jibbering.com/faq/>

If you don't want to do any of the above then just use a pre-made
library like ajaxtoolbox or yahoo ui and follow the tutorials on those
sites. The Yahoo! UI lib might be a better fit for you because there is
a special Yahoo! group/email list for discussing the YUI libraries.

Peter
 

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

No members online now.

Forum statistics

Threads
473,795
Messages
2,569,644
Members
45,358
Latest member
TreyTritt8

Latest Threads

Top