Note that there are some explanatory texts on larger screens.

plurals
  1. POCoffeeScript keeps triggering Error when I'm getting a 200 response back?
    primarykey
    data
    text
    <p>I'm trying to do a <code>remote: true</code> form and I have it all setup, and when I click the submit button, the error action triggers every time. This is how my CoffeeScript is setup:</p> <pre><code>$(document).ready -&gt; $("#new_report").on("ajax:success", (e, data, status, xhr) -&gt; $("#new_report").append "&lt;p&gt;SUCCESS&lt;/p&gt;" ).bind "ajax:error", (e, xhr, status, error) -&gt; $("#new_report").append "&lt;p&gt;ERROR&lt;/p&gt;" </code></pre> <p>And my Reports_Controller</p> <pre><code> def create @report = Report.new(params[:report]) respond_to do |format| if @report.save format.json { render json: "Created", :status =&gt; :created } else format.json { render json: @report.errors, status: :unprocessable_entity } end end </code></pre> <p>And my form:</p> <pre><code> &lt;%= form_for(@report, remote: true ) do |t| %&gt; &lt;p id="reportalert"&gt;&lt;/p&gt; &lt;%= t.text_field :plant_site, placeholder: "Plant Site" %&gt; &lt;%= t.text_field :route_number, placeholder: "Route Number" %&gt; &lt;%= t.text_field :driver_name, placeholder: "Driver name if available" %&gt; &lt;%= t.date_select :date_recorded, html: { class: "input-block-level" } %&gt; &lt;%= t.text_field :action, placeholder: "Action taken" %&gt; &lt;%= t.text_area :report_body, placeholder: "What you witnessed", style: "height: 300px;", class: "input-block-level" %&gt; &lt;%= t.submit "File Report", class: "btn btn-primary btn-large" %&gt; &lt;% end %&gt; </code></pre> <p>But I check the rails log, and it's nothing but a 200 response, no errors, and the information is submitted to the database, so why is the <code>ajax:error</code> triggering? I have also tried replacing the <code>ajax:error</code> and <code>ajax:success</code> with <code>ajaxSuccess</code> and <code>ajaxError</code> but then it just doesn't do anything. Any information would be great thanks.</p> <p>I'm trying to follow: <a href="http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html" rel="nofollow">http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload