why is it that none of my ajax code is running

+1 Mwangi CJ · October 20, 2015
I started learning ajax with Bucky, but up to this point none of my script has run. 

some one check this one below and tell me what's wrong.

The Html "index.html"

<!DOCTYPE>
<html>
<head>
<script src="movies.js"></script>
</head>
<body onload="gametime()">
<div id="theD" />
</body>
</html>




The ajax "movies.js"

function gametime(){
title = document.createTextNode("Here are some things!");
list = document.createElement("ul");

itme1 = document.createElement("li");
text1 = document.createTextNode("Old McDonald");
item1.appendChild(text1);

itme2 = document.createElement("li");
text2 = document.createTextNode("Burger");
item2.appendChild(text2);

itme3 = document.createElement("li");
text3 = document.createTextNode("Ham");
item3.appendChild(text3);

list.appendChild(item1);
list.appendChild(item2);
list.appendChild(item3);

theD = document.getElementById("theD");
theD.appendChild(title);
theD.appendChild(list);
}

Both files are in same  directory.

Post a Reply

Replies

Oldest  Newest  Rating
+1 wernich wilsenach · November 8, 2015
my lecturer always told us "never copy and paste! you'll always make mistakes!" :D

which brings me to the solution to your problem:

itme1 = document.createElement("li");
text1 = document.createTextNode("Old McDonald");
item1.appendChild(text1);

itme2 = document.createElement("li");
text2 = document.createTextNode("Burger");
item2.appendChild(text2);

itme3 = document.createElement("li");
text3 = document.createTextNode("Ham");
item3.appendChild(text3);
  • 1

Javascript

107,068 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators