有人可以告诉我为什么这个PUT方法不起作用.
$.ajax({
type: "PUT",
dataType: "script",
url: '/resources/35',
data:
{
resource : { pos_y: 45, pos_x: 50 }
}
}).done(function( msg )
{
alert( "Data Saved: " + msg );
});
Run Code Online (Sandbox Code Playgroud)
服务器说我已经使用了GET方法,但在我的ajax请求中我输入了:"PUT"
Started GET "/resources/35?resource%5Bpos_y%5D=45&resource%5Bpos_x%5D=50&_=1344001820350" for 192.168.1.89 at 2012-08-03 15:50:20 +0200
Processing by ResourcesController#show as */*
Parameters: {"resource"=>{"pos_y"=>"45", "pos_x"=>"50"}, "_"=>"1344001820350", "id"=>"35"}
User Load (0.3ms) SELECT "users".* FROM "users"
Resource Load (0.1ms) SELECT "resources".* FROM "resources" WHERE "resources"."id" = ? LIMIT 1 [["id", "35"]]
Rendered resources/show.html.erb within layouts/login …Run Code Online (Sandbox Code Playgroud) 我正在使用Rails和jquery,我需要一个带有ajax的动态内容.
但我不知道如何获取当前的用户ID
例如,网址是www.mywebsite.com/users/ 20
在我的javascript文件中,我需要用户ID(20)
$.get("/users/<%= **20** %>.json", function(data)
{
}, "json");
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助.
还有另一种方法吗?
我需要知道当前载波实例的宽度和高度
例如:
image_tag image.photo_url,:width => image.photo.width, :height => image.photo.height
Run Code Online (Sandbox Code Playgroud)
但问题是image.photo.width和image.photo.height不起作用.
有任何想法吗 ?
控制器: @micropost = Micropost.new(params[:micropost])
但是这个form_tag正在发送给我params[:content]而不是params[:micropost][:content]
<%= form_tag( {:controller => :microposts, :action => :create}, :remote => true) do %>
<%= text_area_tag :content, "", :size=> "20x2" %>
...
...
...
<%= submit_tag "submit" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
服务器:
Processing by MicropostsController#create as JS
Parameters: {"utf8"=>"?", "content"=>"sdfsdf", "commit"=>"submit"}
Run Code Online (Sandbox Code Playgroud)