我使用Ajax调用在我的javascript:如何在route.rb中定义此路线?
var myUrl = "/cars/customer_cars"
$.getJSON(
myUrl,
{car_id: car_id, customer_id: customer_id},
function(data) {
//Deal with response data
}
);
但从浏览器的角度来看,myUrl
会像 “/汽车/ customer_cars car_id = 3 & CUSTOMER_ID = 6?” 一些东西,car_id
和customer_id
值取决于用户在页面上的选择。这是两个变量。当发送这个Ajax请求,我想它来调用一个控制器功能,所以我需要在配置myUrl
route.rb
(喜欢的东西
match /cars/customer_cars?car_id=?&customer_id=? , :to =>"cars#some_function"
。我只是不知道语法这个配置。
所以,当请求被发送,CarsController的some_function将被调用。
如何在route.rb中配置myUrl
好的建议,谢谢:) – Mellon 2011-02-14 07:29:28