LoginSignup
0
0

More than 3 years have passed since last update.

JavaScriptでの非同期通信実装①

Posted at

非同期通信を実装

まず結論はrespond_toを用います。
以下、定義です。

respond_to do |format|
  format.html { render ... } 
  format.json { render ... } 
end

html形式だとそのまま該当するビューを返して終わりですが
JSONを返す場合は下の書き方で指定してあげましょう。
非同期通信を施したい箇所をrender以下に記述してください。
なお、記述箇所はやり方にもよりますが
コントローラーのcreateアクション内に記述します。

次は肝となるajaxについて記述します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0