简单的?将 Jquery 数组发布到 Rails 控制器#action
似乎无法弄清楚如何将查询(json)数组发布到rails控制器#action
我就像
var myarray = []; ( with values )
我想发布到的控制器操作一样:
def process
end
我到处都能找到有关如何获取JSON的答案 - > jQuery 但我需要相反的方式。有人知道该怎么做吗?能不能这么难?!
Cannot seems to figure out how I can post a query(json) array to a rails controller#action
I have just like
var myarray = []; ( with values )
My controller action I want to post to:
def process
end
Everywhere I find answers on how to get JSON -> Jquery
But Ill need the other way around. Anyone knows how to do this? Can't be that hard?!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能有几种方法可以做到这一点,但这是一种。使用像这样的 JS 来发布到您的控制器:
然后,在您的控制器中:
现在您有一个与 javascript 中的数组相匹配的数组。
There's probably a few ways to do this, but here's one. Use some JS like this to post to your controller:
Then, in your controller:
Now you have an array that matches what you had in javascript.
jQuery 文档有关于发布的信息: jQuery.post()
这样的东西有帮助吗?
$.post('流程操作路径', {myarray: myarray}
)The jQuery documentation has information about posting: jQuery.post()
Does something like this help?
$.post('path-to-process-action', {myarray: myarray}
)