prototype.js Ajax is slow

3 views
Skip to first unread message

Sam Murk

unread,
Aug 25, 2008, 6:13:41 PM8/25/08
to rubyonra...@googlegroups.com
So I was doing some experimenting with prototype and ajax and discovered
something interesting. When I use the first ajax call the response from
the server take 53ms. When I use the second on using the prototype
functions the request from the server is over 200ms. My question is
why, and can it be fixed?


<p><a href="#" onclick="serverSideAlert();">Call server-side
function</a></p>
<p id="responseTxt"></p>
<script type="text/javascript">
function serverSideAlert() {
var request = new XMLHttpRequest();
request.open('get', '/jstest/server_response', false);
request.send(null);
document.getElementById('responseTxt').innerHTML =
request.responseText;
}
</script>

<script src="/javascripts/prototype.js" type="text/javascript">
</script>

<p><a href="#" onclick="updateElement()">Update element </a></p>
<p id="response"></p>
<script type="text/javascript">
function updateElement() {
new Ajax.Request('/jstest/server_response', { onSuccess: function
(request) {
$('response').update(request.responseText);
}})
}
</script>

Thanks

Sam Murk
--
Posted via http://www.ruby-forum.com/.

Frederick Cheung

unread,
Aug 25, 2008, 6:36:59 PM8/25/08
to rubyonra...@googlegroups.com

On 25 Aug 2008, at 23:13, Sam Murk wrote:

>
> So I was doing some experimenting with prototype and ajax and
> discovered
> something interesting. When I use the first ajax call the response
> from
> the server take 53ms. When I use the second on using the prototype
> functions the request from the server is over 200ms. My question is
> why, and can it be fixed?
>

You might find that the guys on the prototype-scriptaculous list are
more clued up on this.

Fred

Reply all
Reply to author
Forward
0 new messages