Skip to content Skip to sidebar Skip to footer

Rails 3 Image Upload Form Submitting With Http Instead Of Ajax

I am working on a form to submit it by AJAX instead of http. This is the form : <%= form_for(:image, :remote => true, :url => {:controller=> 'questions',:action =

Solution 1:

Got it to work by installing the Remotipart gem . To upload image files using ajax form submission , this is the only way . Find the git here :https://github.com/JangoSteve/remotipart

Solution 2:

JQuery form.sumbit() submits a form the normal way (Not Ajax). You have to do it differently:

$('#submitButton').click( function() {
    $.ajax({
        url: 'some-url',
        type: 'post',
        dataType: 'json',
        data: $('#myForm').serialize(),
        success: function(data) {
              // ... do something with the data...
        }
    });
});

Post a Comment for "Rails 3 Image Upload Form Submitting With Http Instead Of Ajax"