S
Sean Berry
I have an online store that a customer needs customized by having notes for
each product. I have added a javascript function that sends a session id,
unique product id and some user-defined notes to a script using
XMLHttpRequest. The values get there fine and get stored in a database.
Upon checkout (on the checkout page) I now want to pull all of the data back
from the database and display it. I don't need to display the notes in
order to get them to send, I just want to customer to see their notes so
they don't think they are lost.
So, in my checkout page I have a loop that created divs like the following
<div id="notes<number>"></div>
where <number> is an incremental number starting from 1.
Then, inside the div I have a 1x1 transparent image with an onload function
call.
This onload function call looks something like this:
onload="getNotes(<number>,<session_id>, <product_id>)
where <number> is the same incremental number from above and <session_id>
and <product_id> are values available inside my loop.
The function getNotes uses XMLHttpConnect to connect to another script and
using the session_id and product_id it retrieves the notes and should
populate the div with the notes.
My problem is this...
The getNotes function get called, then the "onreadystatechange" function
gets called but only the code outside of the check for the "readyState" and
"status" is executed.
The stuff inside of
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { }
never gets called.
Is this because the function getNotes is getting called too quickly after
the first call? If this was the case, I would expect the last one to
work... since it would be the last call.
Is there some way to fix this? Do I need to call the onreadystatechange
function with a setTimeout so that it loops, checking the readyState and
status?
Thanks for any and all help.
Sorry if I did not explain fully.
each product. I have added a javascript function that sends a session id,
unique product id and some user-defined notes to a script using
XMLHttpRequest. The values get there fine and get stored in a database.
Upon checkout (on the checkout page) I now want to pull all of the data back
from the database and display it. I don't need to display the notes in
order to get them to send, I just want to customer to see their notes so
they don't think they are lost.
So, in my checkout page I have a loop that created divs like the following
<div id="notes<number>"></div>
where <number> is an incremental number starting from 1.
Then, inside the div I have a 1x1 transparent image with an onload function
call.
This onload function call looks something like this:
onload="getNotes(<number>,<session_id>, <product_id>)
where <number> is the same incremental number from above and <session_id>
and <product_id> are values available inside my loop.
The function getNotes uses XMLHttpConnect to connect to another script and
using the session_id and product_id it retrieves the notes and should
populate the div with the notes.
My problem is this...
The getNotes function get called, then the "onreadystatechange" function
gets called but only the code outside of the check for the "readyState" and
"status" is executed.
The stuff inside of
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) { }
never gets called.
Is this because the function getNotes is getting called too quickly after
the first call? If this was the case, I would expect the last one to
work... since it would be the last call.
Is there some way to fix this? Do I need to call the onreadystatechange
function with a setTimeout so that it loops, checking the readyState and
status?
Thanks for any and all help.
Sorry if I did not explain fully.