By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,483 Members | 1,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,483 IT Pros & Developers. It's quick & easy.

Ajax sometimes stops executing

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
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

P: n/a

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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.