我有两个控制器,分别命名为client/orders
和notary/orders
。在“客户端/订单”中有click_me链接。当我点击链接时,我应该将一个阿贾克斯请求传递给notary/orders/pending_orders
和reload the notary/orders/pending_orders
页面。format.js无法在rails 2中工作
这是我的AJAX调用客户端/命令/新
<script>
jQuery.noConflict();
jQuery(document).ready(function(){
alert(9);
jQuery(".test_link").live("click", function(){
alert("am clicked");
jQuery.ajax({
url: "/notary/orders/pending_orders",
dataType: 'script',
type: "get",
data: {data:'hi'},
success:function(){
alert("success");
},
error:function(){
alert("failure");
}
});
})
});
<%= link_to "click me", "javascript:void(0);" , :class => "test_link" %>
这是我在notary/orders/pending_orders
if request.xhr?
respond_to do |format|
format.js { render :js=>'location.reload();',
:location => "notary/orders/pending_orders"}
end
end
但其重载client/orders/new
不notary/orders/pending_orders
。但我想重装 公证/单码/ pending_orders.How我可以做到这一点?
您的回答给了我更多的想法。谢谢回复 – Inaccessible 2013-06-07 05:38:43