473,387 Members | 1,517 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,387 software developers and data experts.

Ajax sometimes stops executing

Hello everyone,

I have a problem with my Ajax page.

I'm jusing prototype-1.4.0.js as framework.

I have a function to populate three listboxes. The items in the
listboxes are from a MYSQL database and are related. The items are
requested by a php page.

Most of the time everything works fine, but sometimes I end u with only
one or two listboxes.
I can't figure out what's going wrong here. I've tested in Firefox and
Internet Explorer, both the same problem.

Does anyone know why my code sometimes stops executing?
Could it be that i made too many requests in a short time so the next
request can't execute because the current has't finished?

Hope anyone has an idea of what's going wrong.

Greetings

CeyloR

Sep 16 '06 #1
9 1650
CeyloR wrote:
Hello everyone,

I have a problem with my Ajax page.

I'm jusing prototype-1.4.0.js as framework.

I have a function to populate three listboxes. The items in the
listboxes are from a MYSQL database and are related. The items are
requested by a php page.

Most of the time everything works fine, but sometimes I end u with only
one or two listboxes.
I can't figure out what's going wrong here. I've tested in Firefox and
Internet Explorer, both the same problem.

Does anyone know why my code sometimes stops executing?
Could it be that i made too many requests in a short time so the next
request can't execute because the current has't finished?

Hope anyone has an idea of what's going wrong.
Well, if it works sometimes, perhaps what you need to create is some
sort of connection manager to support retries.

I use DOM manipulation as opposed to AJAX to do the calls to my
back-end, but they too can timeout or otherwise fail to complete.

So what I do is that each time I make a request I stick an object
in an array that contains the time that the request is being launched,
and enough information to re-issues the request and track te number of
attempts.

I have a setInterval function that periodically scans the array
and re-issues the requests that have gone stale.

The handlers that return a successful result confirm same
by removing themselves from the que.




Sep 16 '06 #2

drclue wrote:
I use DOM manipulation as opposed to AJAX to do the calls to my
back-end, but they too can timeout or otherwise fail to complete.

So what I do is that each time I make a request I stick an object
in an array that contains the time that the request is being launched,
and enough information to re-issues the request and track te number of
attempts.

I have a setInterval function that periodically scans the array
and re-issues the requests that have gone stale.

The handlers that return a successful result confirm same
by removing themselves from the que.

Awesome idea. Do you have any example code of that?

Sep 18 '06 #3
Jake Barnes wrote:
drclue wrote:
>I use DOM manipulation as opposed to AJAX to do the calls to my
back-end, but they too can timeout or otherwise fail to complete.

So what I do is that each time I make a request I stick an object
in an array that contains the time that the request is being launched,
and enough information to re-issues the request and track te number of
attempts.

I have a setInterval function that periodically scans the array
and re-issues the requests that have gone stale.

The handlers that return a successful result confirm same
by removing themselves from the que.


Awesome idea. Do you have any example code of that?

Well, if you have FireFox , you can check out
the alpha version of LAMPjack at www.lampjack.com

That machine is about a month behind the development
machines , while we wait for our admin types to
finish setting up our staging servers,
so we can keep IE in sync.
[ Cracks whip in general direction of admin ]

But if you use the login or click on the [jacks] tab
you'll see a little floating div that displays
the status of transactions.

If you search for "Re: setTimeOut and infinite recursion"
elsewhere in this group you'll see a post of mine related to
simulating a "sleep()" like function and it has some pseudo
code of a very similar form to the overall concept
used on LAMPjack
Sep 18 '06 #4
Hi,

CeyloR wrote:
Hello everyone,

I have a problem with my Ajax page.

I'm jusing prototype-1.4.0.js as framework.
I never used that and probably never will, given the bad reputation that
it has. That said, AJAX is very robust. We make building management
systems (I work at Siemens), and our last product is a web application
which we successfully let run during days, typically up to 2 weeks or
more. During this time, the application polls through web services every
30 seconds. We even tested scenarios where it polled every 5 seconds. It
simply works. That said, I built a security mechanism, which is very
simple: At the very least, if something goes wrong (no server found,
timeout, etc...), the callback method will be called with an error. In
that case, it's easy enough to call the same service again, and then
another time before giving up. With this mechanism, we reduced the
number of "crashes" to almost nothing. Of course, it's almost impossible
to know what prototype does in its insides...

For the record, the application could run even longer if we didn't have
memory problems in IE. Even though we solved most of them in
collaboration with Microsoft (including "security" patches for IE 6 ;-)
there is still one last memory leak which cannot be solved. That's why
we recommend restarting the web browser (not the server!!) every two
weeks or so.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 18 '06 #5
Laurent Bugnion wrote:
Hi,

CeyloR wrote:
>Hello everyone,

I have a problem with my Ajax page.

I'm jusing prototype-1.4.0.js as framework.


I never used that and probably never will, given the bad reputation that
it has. That said, AJAX is very robust. We make building management
systems (I work at Siemens), and our last product is a web application
which we successfully let run during days, typically up to 2 weeks or
more. During this time, the application polls through web services every
30 seconds. We even tested scenarios where it polled every 5 seconds. It
simply works. That said, I built a security mechanism, which is very
simple: At the very least, if something goes wrong (no server found,
timeout, etc...), the callback method will be called with an error. In
that case, it's easy enough to call the same service again, and then
another time before giving up. With this mechanism, we reduced the
number of "crashes" to almost nothing. Of course, it's almost impossible
to know what prototype does in its insides...

For the record, the application could run even longer if we didn't have
memory problems in IE. Even though we solved most of them in
collaboration with Microsoft (including "security" patches for IE 6 ;-)
there is still one last memory leak which cannot be solved. That's why
we recommend restarting the web browser (not the server!!) every two
weeks or so.
Why not use another browser?

--
Ian Collins.
Sep 18 '06 #6
Hi,

Ian Collins wrote:
Why not use another browser?
Our marketing requirements are for IE only for the moment. That said,
apart from a few minor layout problems, our application is fully
compatible (though not as thoroughly tested) with Firefox too.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 18 '06 #7

Laurent Bugnion wrote:
>Of course, it's almost impossible
to know what prototype does in its insides...
That's an odd thing to say. It is completely open-source and it is
quite small - just 48k. You can read over all the code in an afternoon.
You can use JsUnit to do some unit tests with it and figure out how it
works in less than 2 days.

Sep 19 '06 #8
Hi,

Jake Barnes wrote:
Laurent Bugnion wrote:
>Of course, it's almost impossible
to know what prototype does in its insides...

That's an odd thing to say. It is completely open-source and it is
quite small - just 48k. You can read over all the code in an afternoon.
You can use JsUnit to do some unit tests with it and figure out how it
works in less than 2 days.
Sorry, I expressed myself wrongly. What I actually meant is "Of course I
have no idea what prototype does in its insides". Since it appears to
break, my guess is that it doesn't do proper error handling but I didn't
check.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 19 '06 #9
CeyloR wrote:
I'm jusing prototype-1.4.0.js as framework.
Have you tried set the onFailure method for your Ajax.Request options
object? You may be able to pinpoint exactly what the problem is using
this. You could use the XMLHttpRequest object's 'status' property to
figure out if the server scripts were timing out, or giving you 404's,
or what. Or you could just set the onFailure method to try again with
a new request.

E.g.,
<script>
function doRequest(url, myPostOptions)
{
var myAjax = new Ajax.Request(
url,
{
method: 'post',
postBody: myPostOptions,
onSuccess: mySuccessMethod, //Only runs on successful calls
onFailure: myFailureMethod, //Only runs on failed calls
onComplete: myCompleteMethod //Runs for every call
});
}
function myFailureMethod (obj)
{
//do something with obj...
alert(obj['status']);
}
function mySuccessMethod(obj)
{
//do something with obj
}
function myCompleteMethod(obj)
{
//do something with obj
}
</script>

Sep 19 '06 #10

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

Similar topics

17
by: Steve-O | last post by:
The following code works great in FireFox, Opera, Netscape, Safari, and Gecko, but NOT IE. Why? I tried using 'native' js with setInterval and setTimeout, but I get the same result. My IE...
4
by: Seguros Catatumbo | last post by:
Hi guys, i am having some weird issue with an ajax page. I am designing a simple ajax calendar, because the one over yahoo is about 200kb long, and mine is 9kb and really simple. I am using...
1
by: shaunwo | last post by:
I'm an AJAX / DOM Novice (at best) and trying to figure out how to write the value to a couple input fields. I don't remember exactly where I got the ajax.js file I'm using from (went to the website...
3
by: leehanson | last post by:
I have a timer function that displays to the user the current number of seconds left for the current question. It all works fine, however when the timer is ticking down, and the user starts to...
1
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it possible to display an UpdateProgress control when an event calling Response.Redirect is executed? I have a simple webform with an ImageButton and an UpdateProgress control. My...
5
by: wendallsan | last post by:
Hi all, I'm running into a situation where it seems that JS stops executing as soon as I call an eval in my script. I have an Ajax.Request call to a PHP page that builds a JS object and returns...
0
Frinavale
by: Frinavale | last post by:
I have a peculiar problem... Background: I have a function that I don't want the user to execute more than once while they are waiting for it to process; therefore, I disable all of the...
7
by: Andrew Poulos | last post by:
If I have code that looks like this ajax = function(str) { var val = ""; // do some stuff here return val; }; var foo = ajax("string");
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.