Ruby on Rails
Sunday, October 28, 2012
in your js file:
$('.form_id_or_class').live('submit', function() {$.ajax({url: $(this).attr("action"),type: "POST",data: $(this).serialize(),success: function(data) {// do some action},error: function(xhr){var errors = $.parseJSON(xhr.responseText).errors}});return false;});
The only js script i have there is the following and it is in the index.html.erb. I am using this example for File uploader in Ruby on Rails.
Should I just add your code to mine or mine code has to be modified?
<script type="text/javascript" charset="utf-8">
$(function () {
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload();
//
// Load existing files:
$.getJSON($('#fileupload').prop('action'), function (files) {
var fu = $('#fileupload').data('fileupload'),
template;
fu._adjustMaxNumberOfFiles(-files.length);
console.log(files);
template = fu._renderDownload(files)
.appendTo($('#fileupload .files'));
// Force reflow:
fu._reflow = fu._transition && template.length &&
template[0].offsetWidth;
template.addClass('in');
$('#loading').remove();
});
});
</script>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment