简体   繁体   中英

rails and load file using jquery

Hello I am using rails framework and I want to load this simple file using jquery.

I got my index.html.erb

 <div class="letters">
    <div class="letter" id="letter-a">
      <h3><a href="entries-a.html">A</a></h3>
    </div>
    <div class="letter" id="letter-b">
      <h3><a href="entries-b.html">B</a></h3>
    </div>
    <div class="letter" id="letter-c">
      <h3><a href="entries-c.html">C</a></h3>
    </div>
    <div class="letter" id="letter-d">
      <h3><a href="entries-d.html">D</a></h3>
    </div>
 </div>

and my application.js

  $(document).ready(function() {
  $('#letter-a a').click(function(event) {
   event.preventDefault();
   $('#dictionary').load('a.html');
   });
  });

the question is, where should I put my a.html? I tried to put in the same folder as index.html.erb but it doesnt work, why? Thanks.

您可以将a.html放在public目录中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM