Skip to content Skip to sidebar Skip to footer

How To Include A Javascript File With Sinatra Using Ajax

Note: This works fine when I don't use ajax. I have the same behavior with slim and haml. Here is the source for using ajax with Sinatra I am trying to run some javascript in a pa

Solution 1:

Notice that your output of

<script>
  src="about.js"</script>

isn't actually what you likely want. What you really want is probably something more like this:

<scriptsrc="about.js" />

In order to get something like that, you need to add the src attribute as an attribute in the HAML, like this:

%p #{@time}
%script{:src => "about.js"}

The other issue is with your jquery. It should be $('#msg').load, with the # sign, because that is the id of the div.

Post a Comment for "How To Include A Javascript File With Sinatra Using Ajax"