开发者

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

开发者 https://www.devze.com 2023-01-29 23:50 出处:网络
$.post(\"/students/fetch\", { name: \"John\", time: \"2pm\" }, function(data){ alert(\"Data Loaded: \" + data);
$.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

精彩评论

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