473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Ajax Timeouts

Hi I need help with prototype while doing ajax calls. So this is my JS
which does a ajax calls

var ajax1 = new Ajax.Request (
url,
{
method: 'get',
parameters: params,
onComplete: showResults,
onFailure: showFailure
}
);

this calls works fine but i need to know how I can set a timeout saying
after 5 seconds you should give up and show a message to the user how
can this be achieved. I want to achieve this without changing any code
in prototype.js

Does any one have knowledge in using prototype.js to its best, I looked
at this article http://www.sergiopereira.com/articles/prototype.js.html
does anyone know if there is a official documentation for the library.

Last is there a freebie library better than prototype.js

Thank you
C

May 23 '06 #1
17 3253
Chaprasi wrote:
Hi I need help with prototype while doing ajax calls. So this is my
JS which does a ajax calls
Prototype.js is generally avoided by most people in this group.
You won't find much help for it here.
this calls works fine but i need to know how I can set a timeout
saying after 5 seconds you should give up and show a message to the
user how can this be achieved.
I don't know if prototype supports timeouts, but my AjaxRequest library
does:
http://www.ajaxtoolbox.com/request/examples.php
does anyone
know if there is a official documentation for the library.
Part of the issue with prototype.js is that the documentation is almost
non-existent and there doesn't seem to be a good support system for the
library. So users end up coming here, for example, which is annoying.
Last is there a freebie library better than prototype.js


Yes. Many :)

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
May 23 '06 #2
Thank you for the response. I know I implemeted prototype.js but I am
open to nice JS libraries which does all the wrapping for doing ajax.

So can you name a few of these libraries which are better than
prototype.

Thanks
C

May 23 '06 #3
Chaprasi said the following on 5/23/2006 3:16 PM:
Thank you for the response.
Thank you for quoting what you are replying to in the future.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
<URL: http://www.safalra.com/special/googlegroupsreply/ >
I know I implemeted prototype.js but I am open to nice JS libraries
which does all the wrapping for doing ajax.

So can you name a few of these libraries which are better than
prototype.


*Any* library is better than prototype.

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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 23 '06 #4
Matt Kruse wrote:
Chaprasi wrote:
Hi I need help with prototype while doing ajax calls. So this is my
JS which does a ajax calls

Prototype.js is generally avoided by most people in this group.
You won't find much help for it here.


I haven't really looked at prototype.js - would you mind sharing why
it's generally avoided?
May 23 '06 #5
I am not trying to avoid it, I just was thinking if there are better
libraries who can give me handle over timeouts, onerrors.

So far AjaxRequest looks good which is available at
http://www.ajaxtoolbox.com/

Tony wrote:
Matt Kruse wrote:
Chaprasi wrote:
Hi I need help with prototype while doing ajax calls. So this is my
JS which does a ajax calls

Prototype.js is generally avoided by most people in this group.
You won't find much help for it here.


I haven't really looked at prototype.js - would you mind sharing why
it's generally avoided?


May 23 '06 #6
Tony wrote:
Matt Kruse wrote:
Chaprasi wrote:
Hi I need help with prototype while doing ajax calls. So this is my
JS which does a ajax calls

Prototype.js is generally avoided by most people in this group.
You won't find much help for it here.


I haven't really looked at prototype.js - would you mind sharing why
it's generally avoided?


In no particular order:

1. It modifies the protoype of some built-in objects so that
using say, for..in with an array object produces unexpected results.
2. It requires a different syntax, so that instead of using say:

var el = document.getElementById('someID');

you use:

var el = $('someID');

Instead of looping through a number of IDs, you'd use:

var els = $('someID_01', 'someID_02', elRef_03);
3. Having used and become dependent on its syntax, you'll
have to learn 'real' JavaScript at some point.
4. It is utterly undocumented by the author and only very
sparsely commented. Some other attempts at documentation:

<URL:http://blogs.ebusiness-apps.com/jordan/pages/Prototype%20Library%20Info.htm>
<URL:http://www.sergiopereira.com/articles/prototype.js.html>
<URL:http://wiki.script.aculo.us/scriptaculous/show/Prototype>
<URL:http://www.snook.ca/archives/000531.php>
5. There is no support community or blog of any real substance
6. It has about 2,0000 lines of code when only a small subset
might be needed. It is not easy to use only portions,
as many functions are reliant on others. Those dependencies
are not documented.
7. Its feature detection is sparse and it is likely to fail in
many browsers with no chance of recovery
8. It encourages bad coding practice with functions like:

Try.these( func01(...), func02(...), func03(...) );

as a shortcut for multiple try..catch blocks and replacement
for feature detection.

And so on...
--
Rob
Group FAQ: <URL:http://www.jibbering.com/faq/>
May 24 '06 #7
I'm not particularly pro prototype.js but

RobG wrote:
prototype.js
1. It modifies the protoype of some built-in objects so that
using say, for..in with an array object produces unexpected results.


Is the for..in loop problem still a problem or is that something they
have fixed?

5. There is no support community or blog of any real substance


It is possible to try on the rails spinoff list.
-Peter

May 24 '06 #8
pe**********@gmail.com wrote:
I'm not particularly pro prototype.js but

RobG wrote:
prototype.js

1. It modifies the protoype of some built-in objects so that
using say, for..in with an array object produces unexpected results.


Is the for..in loop problem still a problem or is that something they
have fixed?


The official latest version is 1.4, I tested it with 1.5.0_rc0 (see 1.
below). Yes, it's still a problem and likely always will be.

The issue stems from the fact that prototype.js modifies the prototype
of the in-built Array object. The same functionality could have been
achieved by creating a special prototype.js array object (say called
PTArray or _$A or whatever) and modifying that, but that's not how the
author chose to do it.
1. There are 31 extra properties:

each, all, any, collect, detect, findAll, grep, include,
inject, invoke, max, min, partition, pluck, reject, sortBy,
toArray, zip, inspect, find, select, member, entries, _reverse,
_each, clear, first, last, compact, flatten, without
--
Rob
Group FAQ: <URL:http://www.jibbering.com/faq/>
May 24 '06 #9
RobG wrote:
<snip>
2. It requires a different syntax, so that instead of
using say:

var el = document.getElementById('someID');

you use:

var el = $('someID');

<snip>

That is also function name chosen with a disregard for the convention
laid out in the ECMAScript specification where all Identifiers beginning
with '$' are intended it indicate machine generated Identifiers. No
reasonable javascript code should be written without a regard for that
obviously well known/understood convention.

Richard.
May 24 '06 #10
RobG wrote:
Tony wrote:
I haven't really looked at prototype.js - would you mind sharing why
it's generally avoided?


In no particular order:


<list of pretty bad stuff>

Ouch - I can understand why it's not well-liked here.
May 24 '06 #11
Guys now I am using AjaxRequest library and the timeout does not work
when I set async: false, it works for async calls

AjaxRequest.get (
{
'async': false,
'url': 'some url which requests a page that takes 10 secs to
load',
'timeout': 2000,
'onSuccess': 'some sucess which works',
'onTimeout': function(req) { alert('Timed out'); }
}
)

What am I doing wrong?

Thanks,
C

Matt Kruse wrote:
Chaprasi wrote:
Hi I need help with prototype while doing ajax calls. So this is my
JS which does a ajax calls


Prototype.js is generally avoided by most people in this group.
You won't find much help for it here.
this calls works fine but i need to know how I can set a timeout
saying after 5 seconds you should give up and show a message to the
user how can this be achieved.


I don't know if prototype supports timeouts, but my AjaxRequest library
does:
http://www.ajaxtoolbox.com/request/examples.php
does anyone
know if there is a official documentation for the library.


Part of the issue with prototype.js is that the documentation is almost
non-existent and there doesn't seem to be a good support system for the
library. So users end up coming here, for example, which is annoying.
Last is there a freebie library better than prototype.js


Yes. Many :)

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


May 24 '06 #12
RobG <rg***@iinet.net.au> writes:
The issue stems from the fact that prototype.js modifies the prototype
of the in-built Array object. The same functionality could have been
achieved by creating a special prototype.js array object (say called
PTArray or _$A or whatever) and modifying that, but that's not how the
author chose to do it.


How would that work? Would "new PTArray" create and return a new
normal array and assign all the extra methods on each creation?

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
May 24 '06 #13
Lasse Reichstein Nielsen wrote:
RobG writes: <snip>
The same functionality could have been
achieved by creating a special prototype.js array object (say
called PTArray ...

<snip>
How would that work? Would "new PTArray" create and return
a new normal array and assign all the extra methods on each
creation?


It would pretty much have to as that is the only way of having an
object with the Array's special [[Put]] method. But why not as the
augmentation is only a set of assignments.

Richard.

May 24 '06 #14
try the following line right after you above code:

setTimeout( function(){
ajax1.transport.abort();
alert('Sorry, dude. I gave up on the call.');
} , 5000);

- Sergio Pereira

May 24 '06 #15
Guys any idea why this call is failing in Firefox, but in Internet
explorer it works fine.

AjaxRequest.get (
{
'async': false,
'url': 'some url which requests a page that takes 10 secs to
load',
'timeout': 2000,
'onSuccess': function(req) { alert('Sucess'); },
'onTimeout': function(req) { alert('Timed out'); }
}
)

So in IE this call is success but not in firefox. :(

Thanks,
C

se*******@gmail.com wrote:
try the following line right after you above code:

setTimeout( function(){
ajax1.transport.abort();
alert('Sorry, dude. I gave up on the call.');
} , 5000);

- Sergio Pereira


May 25 '06 #16
Chaprasi wrote:
Guys any idea why this call is failing in Firefox, but in Internet
explorer it works fine.
AjaxRequest.get (
{
'async': false,
'url': 'some url which requests a page that takes 10 secs to
load',
'timeout': 2000,


First of all, don't use async:false. It's generally a Bad Thing.

Second, a timeout won't work here because all code stops and waits for the
request to finish (thus, sync).

Simplify your problem: Use async.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
May 25 '06 #17
I agree with what you are saying. So how do I fire a validation check
where I need a response from the server like validating zip codes
without posting the form back. And what happens if this call times out
or if there is any network errors, how do I track those?

Can that be achieved with AjaxRequest?

Thanks,
C

Matt Kruse wrote:
Chaprasi wrote:
Guys any idea why this call is failing in Firefox, but in Internet
explorer it works fine.
AjaxRequest.get (
{
'async': false,
'url': 'some url which requests a page that takes 10 secs to
load',
'timeout': 2000,


First of all, don't use async:false. It's generally a Bad Thing.

Second, a timeout won't work here because all code stops and waits for the
request to finish (thus, sync).

Simplify your problem: Use async.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


May 26 '06 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: p2esp | last post by:
Hello, I'm using the xmlrpclib module to contact an XMLRPC server that takes a long time to send results back. My client timeouts. The question is whether there is a way to have an xmlrpclib...
4
by: Laphan | last post by:
Hi Guys I've been using text files for Tab-Delimited/ADO/ASP sites so that users can update and display their products lists through my system with relative ease. Only problem is that for the...
2
by: mircu | last post by:
Hi, I need a quick solution to make my application behave correctly when one of these timeouts occurs. I have some logic in session_start but when the authentication cookie timeouts the user is...
2
by: Fraijo | last post by:
how can i disable session timeouts without affecting any program codings?
1
by: AV | last post by:
I have a web server in production running IIS 6 (Windows Server 2003 SP1) and hosting multiple virtual websites with each website hosting many ASP.NET applications in virtual directories. Each...
5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
2
by: webdevaccount | last post by:
Hello, I am using a Timer and an UpdatePanel control. The Timer is set to 1000 milliseconds, and therefore results in many server request timeouts error (logical). The Server Request Timeout...
1
by: Lloyd Sheen | last post by:
It seems that debugging AJAX Web services is about impossible. I have googled and found the Sys.Net.WebRequestManager.set_defaultTimeout call. I set the value to 15000 which is supposed to be 15...
10
by: Zytan | last post by:
I have a TcpClient. I set the read/write timeouts at 1 minute (in milliseconds). I get a NetworkStream from it and confirm the timeouts still exist. I do a NetworkStream.Write() and then a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.