ajaxSubmit Issues
ajaxSubmit Issues
Hi,
I am a newbee in this jQuery. I trying to submit a form with a file upload functionality. This below explained code submits the form successfully, but does not include the Image part. The code is as below.
Form =============================================================
<% remote_form_for(:user,@user,:url => {:controller => "account",:action=>"update_profile"}, :html => {:method => :post, :multipart => true, :id => "edit_form"}) do |f| -%>
<table align="center" class="signup_table">
<tr><td width=50%>
<div id="account_fields_partial_div">
<%=render :partial=>'/account/account_fields_partial',:locals=>{:f => f,:requirement_type=>"Edit"}%>
</div>
</td>
<td>
<div id="account_prof_details_partial_div">
<%=render :partial=>'/account/account_prof_details_partial',:locals=>{:f => f,:requirement_type=>"Edit"}%>
</div>
</td></tr><tr><td>
<%=render :partial=>'/account/submit_partial',:locals=>{:f => f,:requirement_type=>"Update My Profile"}%>
</td></tr></table>
<% end -%>
Script ==============================================================
$(document).ready(function() {
$.ajaxSetup({
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept","text/javascript")}
})
$("#edit_form").submit( function(){
var options = {
url: '/account/update_profile',
dataType: 'script',
type: 'POST'
};
$(this).ajaxSubmit(options);
return false;
})
})
Action in the Controler: ====================================================
def update_profile
.
.
.
respond_to do |format|
format.html
format.js
end
end
js.erb file ==========================================================
<% if @error_messages != ""%>
$("#error_messages").html("<%=@error_messages%>");
$("#error_messages").slideDown(1000);
<%else%>
$("#error_messages").slideUp(1000);
$("#edit_form_div").slideUp(1000);
$("#edit_form_div").html("<%= escape_javascript(render :partial => 'account/edit_form_partial',:locals => {:user => @user})%></br></br>").slideDown(1500);
<%end%>
=====================================================================
I know this is too much but, sorry can't help this. I am using ajaxSubmit from the jQuery.form.js just for the multipart and thats not working for me .. :)
Please some angel point out where I am exactly going wrong or probably some place to start with.
Regards,
Angel ...