Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.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
RubyonRails3呈现JSON数据_Json_Ruby On Rails 3_Extjs - Fatal编程技术网

RubyonRails3呈现JSON数据

RubyonRails3呈现JSON数据,json,ruby-on-rails-3,extjs,Json,Ruby On Rails 3,Extjs,我试图将我的对象呈现为JSON,但是当我尝试使用ExtJS在视图中访问它时,我没有得到任何值,它是未定义的。我需要在响应中发送success属性。 这是我的密码: 在控制器中渲染: render:text=>{success:true,userdata:{admin.to_json}},其中admin是我的模型对象 在视图中,我使用ExtJS编写了以下处理程序函数: 成功: function(form,action){ Ext.SM.set("uname

我试图将我的对象呈现为JSON,但是当我尝试使用ExtJS在视图中访问它时,我没有得到任何值,它是未定义的。我需要在响应中发送success属性。 这是我的密码: 在控制器中渲染:

render:text=>{success:true,userdata:{admin.to_json}},其中admin是我的模型对象

在视图中,我使用ExtJS编写了以下处理程序函数:

成功:

     function(form,action){
                Ext.SM.set("uname",action.result.userdata.fname + ' ' + action.result.userdata.lname);
                NWST.init();}
我没有得到fname和lname的任何值。
有人能帮我吗…

先添加:success=>true到@admin,然后render:json=>@admin

您尝试过更改render:text=>。。。要呈现:json=>。。。看看会发生什么?@admin[:success]=true@neeraj:请阅读了解如何使用Stackoverflow