0

I'm using the concept for dynamic select menus provided here:

http://samuelmullen.com/2011/02/dynamic-dropdowns-with-rails-jquery-and-ajax/

I've isolated my problem to the first parameter for .post in this code:

  this.change(function() {
    $.post("dvbd", that.val(), null, "script");
  });

I expect for the dvbd.js.erb file in the parent directory to be found and the jQuery contents therein executed. So, the location would be:

http://localhost:3000/parentdir/dvbd.js.erb

Instead, I get a 404 error where the location "http://localhost:3000/parentdir/dvbd is not found." So I don't even make it to the point to check if the javascript is actually being executed because the file where it resides is never found. However, I'm pretty sure it works because putting the same code in the local file results in successful execution of putting "Hello" in the Dave div:

$("#dave").html('Hello');

I can't really put the code in the local file because this isn't the code I'm actually trying to run. But since this fails first, it has to be solved first.

4

1 回答 1

0

该位置将与描述的不同。地点将是:

http://localhost:3000/parentdir/dvbd

在您的控制器(parentdir)和方法 dvbd 中,您需要添加:

  respond_to do |format|
    format.js
  end

无论如何-问题是您没有在控制器中定义方法 dvdb

于 2013-02-02T12:31:14.863 回答