> I am brand new to MochiKit and am real rusty on js, but... The problem > I am haveing is that the js I am using keeps throwing an error in > Firefox saying "Error: replaceChildNodes is not defined"
One of three things is happening: 1. You forgot the <script src="MochiKit/MochiKit.js"></script> for MochiKit 2. You are using JSAN but not JSAN.use('MochiKit', ':common') 3. You are using Dojo Toolkit When using JSAN (without ':common') or Dojo, MochiKit doesn't export symbols. You'd have to use MochiKit.DOM.replaceChildNodes, MochiKit.Async.loadJSONDoc, etc. > Here is the js I am using cut and pasted from the html: > > <SCRIPT TYPE="text/javascript"> > function requestPageList() { > /* d = loadJSONDoc("/buTest?turbogearsfmt=json"); > d.addCallback(showPageList); */ > var quote= new Array(1); > quote[0] = "<P>It worked!!</P>"; > showPageList(quote); > } > > function showPageList(result) { > replaceChildNodes(null, null); > } > </SCRIPT> Clearly you shouldn't be calling replaceChildNodes with null as the first parameter... that needs to be the id of an element as a string, or a reference to an element. However, there's three things about your implementation of requestPageList that are off: - Calling "new Array()" is silly, arrays have syntax. - You should ALWAYS declare your local variables, default scope is global. If you don't, you can't safely call a function from another function because they might clobber each other's variables! - MochiKit.DOM accepts DOM elements, not raw markup. If you want to set the innerHTML on something, you should just do it that way. function requestPageList() { if (false) { var d = loadJSONDoc("..."); } else { var d = succeed([P(null, "It worked!!")]); } d.addCallback(showPageList); } -bob