Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ui 远程调用后将值从控制器返回到js_Jquery Ui_Ruby On Rails 3.2 - Fatal编程技术网

Jquery ui 远程调用后将值从控制器返回到js

Jquery ui 远程调用后将值从控制器返回到js,jquery-ui,ruby-on-rails-3.2,Jquery Ui,Ruby On Rails 3.2,我知道这有点基本,但我在rails应用程序中将数据从controller发送到.js.erb页面时遇到问题 我可以使用remote=>true从我的link_函数调用我的主控制器。 此代码位于我的index.html.erb页面中 <%= link_to 'Process', post, method: :delete, data: { confirm: 'Are you sure?' },:remote=>true,:class=>"test" %> 这很简单,但您能

我知道这有点基本,但我在rails应用程序中将数据从controller发送到.js.erb页面时遇到问题

我可以使用remote=>true从我的link_函数调用我的主控制器。 此代码位于我的index.html.erb页面中

<%= link_to 'Process', post, method: :delete, data: { confirm: 'Are you sure?' },:remote=>true,:class=>"test" %>
这很简单,但您能告诉我如何将pass@test设置为index.js.erb,以便我可以将其用作数据并检索它吗


谢谢

您可以在js模板中使用与html模板相同的实例变量。唯一需要注意的是,您需要将服务器输出包装在
javascript\u escape

# index.js.erb
$('#some-div').html('<%= j(@test) %>)
#index.js.erb
$('#some div').html(')

j
javascript\u escape的别名

好的,我知道了。谢谢。。。json呢。我们如何在.js.erb文件中检索它??
# index.js.erb
$('#some-div').html('<%= j(@test) %>)