It is great you got your code to work, but experience suggests that
you did not
fix the real problem. While Rails idiosyncrasies have gotten to me, it
is
highly unlikely that changing the second line to be after the first is
the issue.
What has helped me before is to delete the first two lines and retype
them.
You might have a special character lurking.
Just an additional suggestion for debugging this kind of thing, since
it is an asynchronous request you don't see what is really happening
in the dev log. But if you run firebug in firefox you will be able to
see the ajax request being made in the debugging console and will most
likely be able to see what error message is coming back.