Jump to content


Photo

Strange Error On Utils.js - Chapter 3 - Coffee Maker


  • Please log in to reply
1 reply to this topic

#1 Luciana Machado

Luciana Machado

    New Member

  • Members
  • Pip
  • 2 posts

Posted 12 April 2009 - 05:15 PM

Everything else on the exercise worked, except the last function, that tells the coffee is ready. When the timer finishes, the javascript errrors at the text-utils code :

Error: el.appendChild is not a function
Source File: http://www.luciana.p...e/text-utils.js
Line: 5


------------- TEXT-UTILS.JS :

function replaceText(el, text) {
if (el != null) {
clearText(el);
var newNode = document.createTextNode(text);
el.appendChild(newNode); <<<<<<<<<<< THE ERROR REFERS TO THIS LINE
}
}

---------------------------------


------------ serveDrink FUNCTION :

function serveDrink()
{
// quando a cafeteira tiver terminado, serve a bebida
if( request.readyState == 4 )
{
if( request.status == 200 )
{
var response = request.responseText;

//descobre quem fez o pedido e de qual cafeteira veio
var maker = response.substring( 0, 1 ); // '2Jim'
var name = response.substring( 1, response.length );

if( maker == "1" )
{
document.getElementById( "coffeemaker1-status" );
replaceText( coffeemaker1-status, "Idle" );
}
else
{
document.getElementById( "coffeemaker2-status" );
replaceText( coffeemaker1-status, "Idle" );
}

alert( name + ", your coffee is ready!" );
}
else
{
alert( "Error! Request status is: " + request.status );
}
}
}

--------------------------------------------

ANY IDEA OF WHAT COULD IT BE ??

THANKS !

[]S


#2 Jhenna Lopez

Jhenna Lopez

    New Member

  • Members
  • Pip
  • 1 posts

Posted 07 January 2012 - 06:56 PM

You don't have brackets around a lot of your if clauses so your else if statements break. double check your conditions.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users