开发者

get response from a action in ruby on rails, using jquery

$.post("/students/fetch", { name: "John", time: "2pm" },
   function(data){
   alert("Data Loaded: " + data);
  });

How can return "Any sample text from a action in ruby and rails.". I want to do something li开发者_Python百科ke:--

def fetch
  // do something... some processing... and finally
  return "any random string "  
end

So whole story should be something like:--

  1. Send a post request.
  2. return some string from the action.
  3. alert that string which we got from that action.


to return text from an action:

def fetch
  render :text => "any random string"
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜