Forum: Ruby on Rails first day on rails...and already hamstrung!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-18 20:45
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.
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2009-05-18 21:01
(Received via mailing list)
On Mon, May 18, 2009 at 11:45 AM, Mk 27
<rails-mailing-list@andreas-s.net> wrote:
>
> I'm reading along with "Ajax on Rails" (2007)

a bit old, but ...

> and the first exercise goes like this:

> Then editing example/app/views/myaction.html.erb to look like this:
>
> <script language="javascript" type="text/javascipt">

> 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.

1) the language attribute is not only not "necessary", it's deprecated;
    don't use it.

2) spell text/javascript correctly and it should work as intended.

HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
68814ed988eee4f21b2cd07353e5e445?d=identicon&s=25 Mk 27 (mk27)
on 2009-05-18 21:06
Hassan Schroeder wrote:

> 1) the language attribute is not only not "necessary", it's deprecated;
>     don't use it.

Thanks.

>
> 2) spell text/javascript correctly and it should work as intended.

Sheesh.  New things make me crazy paranoid.
This topic is locked and can not be replied to.