I'm reading along with "Ajax on Rails" (2007) and the first exercise goes like this:
rails example cd example script/generate controller chap2 myaction script/server
Then editing example/app/views/myaction.html.erb to look like this:
<script language="javascript" type="text/javascipt"> function fone() { var request = new XMLHttpRequest(); request.open('get', '/chap2/somewords', false); request.send(null); alert(request.responseText); } </script> <h2 onclick="fone();">Hello World?</h1>
Firebug then says fone() is not defined. In the book the script is after the html but this does not matter.
What's the deal? I have not tried src'ing an external script (as I am not sure where I would put that). I can't really proceed if the js in the view is just going to be ignored. I also added the language="javascript", as this seems to be necessary sometimes in normal html pages, but this does not help.