JangoSteve / remotipart

Rails jQuery file uploads via standard Rails "remote: true" forms.
http://os.alfajango.com/remotipart
Other
1k stars 215 forks source link

ajax:success error? try this #111

Open ghost opened 10 years ago

ghost commented 10 years ago

Add the :data => { :type => 'text' } to the form tag

:html => { :multipart => true, :data => { :type => 'text' } } }

works for you?

toppa commented 9 years ago

Thanks! I was uploading files successfully, but my JS was nonetheless getting an ajax:error response. Adding :data => { :type => 'text' } to the form fixed it.

If it helps anyone, this is my controller code:

  def create
    @contact_document = ContactDocument.new(contact_document_params)

    if @contact_document.save
      render json: @contact_document
    else
      render json: { errors: @contact_document.errors.full_messages }, status: 422
    end
  end

A successful save was returning an ajax:error condition before I added :data => { :type => 'text' } to the form. After that, it started returning the ajax:success condition I was expecting.

tomprats commented 9 years ago

This same thing was happening for me. I tried type: :text and it was still a little off. Using type: :json worked for me!

CodeMonkeySteve commented 8 years ago

type: 'text' works for me (with an HTML response).

rapito commented 6 years ago

This should probably be on the Readme.md

samstickland commented 5 years ago

I also had this problem and then found this issue. It would be good if this was on the README.