【发布时间】:2018-10-12 07:05:57
【问题描述】:
我想使用带有导轨的Ajax 在文本框中显示country currency code。
如果选择国家 India,则在价格文本框中获取国家/地区货币符号。
我参考了一些他们说使用Ajax 的网站,但我不知道如何在rails 中使用ajax
这是尝试过的代码:
<script type="text/javascript">
$("#manageproject_location").change(function() {
var country = $('select#manageproject_location :selected').val();
$.ajax({
url: 'my-controller-name/function-name',
data: { country : country },
dataType: json,
type: 'POST',
success: function(result)
{
$('manageproject_symbol').val(); // here append courrency sybmbol
}
});
});
</script>
控制器:
class ManageprojectsController < ApplicationController
def new
@manageproject=Manageproject.new
@all=Location.all
end
end
注意:我不知道如何在 rails 中使用 ajax。
提前谢谢....!
【问题讨论】:
-
你定义了受人尊敬的路线和
controller#action吗? -
@Pavan 不,我没提那个..?
标签: ruby-on-rails ajax