Hi…
I am having a problem with a short little javascript that I want to load information from the server – it works okay and does what it is supposed to UNLESS you remove the “Alert” line. I imagine using “alert” will cause some type of page refresh – as you can see the javascript parses the data prior to displaying it. Attached is the javascript code as well as the code for the page it calls – just in case somebody needs to work with it
can anybody give me a hint?
Thank you
P.J.
Here is the code:
<body onload=”pageDataLoad()”>
<div id=”serverData” style=”display: none”>
<div id=”returnData”></div>
</div>
<div id=”tempOutput”>smoo</div>
<script language=”javascript”>
function pageDataLoad(){
ajaxLoadData(‘ajax_port.aspx?searchTerm=faro&’,’serverData’);
onServerDataLoad();
}
function ajaxLoadData(url,id) {
if (document.getElementById) {
var x = (window.ActiveXObject) ? new ActiveXObject(“Microsoft.XMLHTTP”) : new XMLHttpRequest();
}
if (x) {
x.onreadystatechange = function() {
if (x.readyState == 4 && x.status == 200) {
el = document.getElementById(“serverData”);
el.innerHTML = x.responseText;
}
}
x.open(“GET”, url, true);
x.send(null);
}
}
function onServerDataLoad(){
var myout;
var lclItem;
var itemArray;
var lclObj;
myout = “”;
// it does nto work properly without the following line of code
[COLOR=”Red”][B]alert(“serverData”)
// everything will work if this is not there.
for(lclItem in returnData.all){
if(lclItem != “length”){
itemArray = document.getElementById(lclItem)
myout = myout + lclItem + ” = ” + itemArray.innerHTML + “<br />n”;
}
}
tempOutput.innerHTML = myout;
}
Also here is the code for commpage.html
<div name=”returnHeader” id=”returnHeader”>
<span id=”fieldCount”>3</span>
</div>
<div name=”returnData” id=”returnData”>
<span id=”myMessage”>This is a message</span>
<span id=”myName”>FARO Webmaster</span>
<span id=”testField”>This is some data.</span>
</div>
<script language=”javascript”>
parent.confirmData();
</script>