title: rails respond_to format.js API
body: <p>I am an experienced JAVA and C++ developer and I am trying to understand how rails works.</p>
  
  <p>I got this code below:</p>
  
  <pre><code>respond_to do |format|
        if @line_item.save
          format.html { redirect_to store_url }
          format.js { render :json =&gt; @line_item, :mime_type =&gt; Mime::Type.lookup('application/json'), 
                  :callback =&gt; 'javascriptFunction' }
  </code></pre>
  
  <p>and I've been searching the api that defines what I can pass inside the <code>format.js {}</code> but I could not find.. </p>
  
  <p>first of all: what kind of statement is <code>format.js</code>, is that a variable? </p>
  
  <p>and most important: what attributes can I pass into format.js {} ? can you pass the direct link? I've searched  over the <a href="http://api.rubyonrails.org/" rel="noreferrer">http://api.rubyonrails.org/</a> </p>