Hello vinod
Thanks for the fast reply. Sorry I wasn't close by. I am kinda slow at this, so I will have to play with the code you sent, but I will for sure. In the meantime heres a stripped down version of my code. Its pretty much self explanatory, but what I want, is for the value of innerHTML in A to be available for use after submitting only once. The refresh of values seems to be tied to submit buttons and alert calls. Btw I am only interested in making it work in IE for the time being.
This all works. (just not like I want it to:()
Mypage.html
<html>
<head>
<script src="getdata.
js"></script>
<script language = "JavaScript" type = "text/javascript">
var data = ""
var dataA = ""
function prepdata(){
data = document.getElementById("data").value
getdata(data)
document.getElementById("B").innerHTML=document.ge tElementById("A").innerHTML
dataA = document.getElementById("A").innerHTML
alert("This is what shows in A before calling alert : "+dataA)
document.getElementById("B").innerHTML=document.ge tElementById("A").innerHTML
dataA = document.getElementById("A").innerHTML
alert("This is what shows after calling alert : "+dataA)
}
function copydata(){
document.getElementById("B").innerHTML=document.ge tElementById("A").innerHTML
}
</script>
</head>
<body>
Data to send: <input type="text" size="40" id="data" value="Send this to retrieve new data"/>
<input type="button" name="send" onclick="prepdata()" value="Submit"/>
Submiting twice causes data to update
<br></br><br></br>
A. Data returns here, and then is copied to B:<p><div id="A"> A data</div></p><br></br>
B. Data read from A :<p><div id="B">blank</div></p><br></br>
Manual copying of data from A to B causes correct updated reading of innerHTML:<br></br>
<input type="button" name="copy" onclick="copydata()" value="Submit"/>
</body>
</html>
getdata.
js
var xmlHttp
function getdata(str){
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
alert ("Your browser does not support AJAX!");
return;
}
var url="getdata.php";
url=url+"?data="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged(){
if (xmlHttp.readyState==4){
document.getElementById("A").innerHTML=xmlHttp.res ponseText;
mydata=xmlHttp.responseText;
}
}
function GetXmlHttpObject(){
xmlHttp=null;
try {
xmlHttp=new XMLHttpRequest();
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
getdata.php
<?php
$response="Data from PHP";
echo $response;
?>
Thanks again,
oldBroh