Forum Moderators: open
I am making an application with AJAX with the following flow,
1 - visitor click next button and more data is fetched from MySQL using PHP and displayed on the page. Visitor can click previous button to come back and see what he had selected and what was the system response to it. to store the history of system response i am using php sessions. every time system display response i store KEYWORD in session array for which the response is displayed. And every time user clicks previous button i check if the KEYWORD is present in the session array before and if yes i call the response function with the the KEYWORD to display it to tell the visitor what he had selected.
Every Step has four KEYWORDS with radio button so that visitor can select one and then press show response button to see the response of the system.
here is the code to check session array for the KEYWORD
Code:
for (var i=0; i<spn.length; i++) {
f[i].value = res[i+1];
checkHistory(res[i+1])
//alert (res[i+1])
spn[i].innerHTML = res[i+1];
}
checkHistory is sending every KEYWORD to response function that checks if it is present in the session array and if yes then it displays the system response otherwise no.
now the problem is that visitor selects keyword1, keyword2 or keyword3 to see its response and when comes back he cant see the response form the history BUT if the visitor selects keyword4 and sees its response then he can see the response from the history.
I placed a ALERT after calling checkHistory() and noticed that system does display the response from the history for keyword 1, 2 and 3. but when checkHistory is called for the fourth time it removes the response of keyword 1, 2 and 3.
despite I have this code where i fetch record from DB in checkHistory function body,
Code:
if (http.readyState == 4) {
if(http.status==200) {
var results3=http.responseText;
var res3 = results3.split('¦')
// alert(res3[1] + res3[0] )
if(res3[0] == "Yes") {
showRec(res3[1])
//alert(res3[1] + res3[0])
}
my output comes in the form of,
Code:
Yes¦system response fetched from DB if keyword found in session array
and if output not found then
Code:
No¦Undefined
after exploding i get "Yes" in res3[0] and response in res3[1]. i have checked it with ALERT that if they keword found it execute the ALERT inside IF statement. so logically if "Yes" is not coming then IF is not executed and hence ShowRec() function is not called so it should not remove the value of Response DIV after calling checkHistory() for Keyword4. But it is doing it.
thanks for reading long thread and bundle of thanks in advance for replying ....