0

I know the code, but not the tags to enclose it within.
Current HTML:

<!DOCTYPE html>
<html>
<head>
<script language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('#Reindeer').sortable();
});
</script>
<script>
if (window.XMLHttpRequest)
  {
  xmlHttp=new XMLHttpRequest();
  }
else
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlHttp.open("GET","xmlExample.xml",false);
xmlHttp.send();
xmlDoc=xmlHttp.responseXML;

function displayComments()
{
content=(x[i].getElementsByTagName("content")[0].childNodes[0].nodeValue);
txt="Comment: "+content;
document.getElementById("comments").innerHTML=txt;
}
</script>

<link type="text/css" rel="stylesheet" href="styleReindeer.css">
</head>
<body onload="displayComments()">
<ul id="Reindeer">
<li>Dasher</li>
<li>Dancer</li>
<li>Prancer</li>
<li>Vixen</li>
<li>Comet</li>
<li>Cupid</li>
<li>Donner</li>
<li>Blitzen</li>
<li>Rudolph</li>
</ul>
<Form>
<input type="text" name="commBody">
<input type="submit" value="Submit Comment!">
</Form>
<div id="comments">
</div>
</body>
</html>

What do I put in the <script> tags? Or am I going about it all wrong?

1
Contributor
1
Reply
3
Views
4 Years
Discussion Span
Last Post by chris99
0

Nevermind, it turns out that XML won't work offline. Trying to cheat it only gets cross-origin errors. That may be what's causing every error I've found. Current code:

<!DOCTYPE html>
<html>
<head>
<script language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('#Reindeer').sortable();
});
</script>
<script>
if (window.XMLHttpRequest)
  {
  xmlHttp=new XMLHttpRequest();
  }
else
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlHttp.open("GET","xmlExample.xml",false);
xmlHttp.send();
xmlDoc=xmlHttp.responseXML;
x=xmlDoc.getElementsByTagName("comment");

function displayComments()
{

content=(x[i].getElementsByTagName("content")[0].childNodes[0].nodeValue);
txt="<div>Comment: "+content;
document.getElementById("comments").innerHTML=txt;
}
</script>
<link type="text/css" rel="stylesheet" href="styleReindeer.css">
</head>
<body onload="displayComments()">
<ul id="Reindeer">
<li>Dasher</li>
<li>Dancer</li>
<li>Prancer</li>
<li>Vixen</li>
<li>Comet</li>
<li>Cupid</li>
<li>Donner</li>
<li>Blitzen</li>
<li>Rudolph</li>
</ul>
<Form>
<input type="text" name="commBody">
<input type="submit" value="Submit Comment!">
</Form>
<div id="comments">
</div>
</body>
</html>

Will this work when the files are on a server?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.