If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

callback function gets called twice

So I am getting some data via AJAX, from a Java servlet on the server side.

I had some alert boxes set up, and the request gets submitted only once.
But, the callBack function in the onreadystatechange iterates through the states twice - reaches state == 4 , status == 200, does its work, and then goes through the states again... I have no idea why this is happening?

I can't see anything wrong with the bits you have given us, but clearly this is an extract of the whole page, so maybe the fault lies elsewhere?
Have you tried debugging this - first thing I would want to know is if the function is being called twice, or if it is looping somehow, and to double-check whether the callback was somehow getting registered twice.

Resolved

If I am working on anything significant, I usually set up a DIV that I can use as a logging console - there is almost nothing that is as frustrating as putting an alert within an onfocus method (or something similar) and having it loop endlessly as a result...