I have a webpage - lets call it index.php. Using AJAX I load content from another page after a dropdown selection - lets call this one catalog.php.
catalog.php has an empty DIV, that, using jQuery, gets some text from yet another page - this final one will be called data.php. It replaces the contents of the DIV, and refreshes every 1 second.
If I go directly to catalog.php (using the proper GET), the jQuery will run and the DIV will update every second as needed.
However, if I go to index.php - catalog.php will load and run, but the DIV remains empty, and it will not populate the DIV with data.php.
What's going on here?
Sample code from index.php:
<script>
function showForm(str) {
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","catalog.php?q="+str,true);
xmlhttp.send();
}
</script>
Sample code from catalog.php:
<div id="divstuff"></div>
<script src="jq.js"></script>
<script type="text/javascript">
window.setInterval(function(){
$("#divstuff").load("data.php?data=somedata");
}, 1000);</script>
It's all echo'd via PHP and such. data.php just has some basic stuff printed with PHP.