Forum Moderators: open
<script type="text/javascript" language="javascript">
var xmlhttp = false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
function makerequest(serverPage, objID) {
var obj = document.getElementById(objID);
xmlhttp.open("GET", serverPage);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
obj.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
</script>
The makerequest() function works fine however the code does not validate because of the &&. If i escape them with & then the function does not work but the page validates. Any help would be appreciated as I don't want to host an invalid page. The book is from 2006 but that can't be the reason, can it?
//place javascript code in here
/*]]>*/
</script>
The CDATA opening and closing tags are only required inside of javascript tags which are actually on the page, and are not necessary if the script tags are just an src link to an external .js file (which also does not need the CDATA tags inside)