//replace $(document).ready(function(){ $('.delete_file').click(function(){ var url = '/admin/ajax_delete_file/'; $this = $(this); $.get( url, {'id': $(this).attr("value")}, function(j){ if (j = 'success'){ $this.parent().parent().remove(); } else{ console.log('error'); } });//end get return false; });//end delete $('#file_form').submit(function(){ var fileData = new FormData($(this)[0]);//file (request.FILES) var formData = $(this).serialize();// another data (request.POST) //check if object is new if ($('#obj_id').val() != '') { var url = '/admin/ajax_post_file/'+$('#obj_id').val()+'/'; } else { var url = '/admin/ajax_post_file/' } $.ajax({ url: url, //server script to process data type: 'POST', xhr: function() { // custom xhr var myXhr = $.ajaxSettings.xhr(); if(myXhr.upload){ // check if upload property exists myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // for handling the progress of the upload } return myXhr; }, //Ajax events success: postSuccess, error: function(){ alert('error'); }, // Form data data: (formData, fileData), //Options to tell JQuery not to process data or worry about content-type cache: false, contentType: false, processData: false });//end ajax return false; });//end submit /* $('#photo_form').submit(function(event){ event.preventDefault() var fileData = new FormData($(this)[0]);//file (request.FILES) var formData = $(this).serialize();// another data (request.POST) if ($('#obj_id').val() != '') { var url = '/admin/ajax_post_photo/'+$('#obj_id').val()+'/'; } else { var url = '/admin/ajax_post_photo/' } $.ajax({ url: url, //server script to process data type: 'POST', xhr: function() { // custom xhr var myXhr = $.ajaxSettings.xhr(); if(myXhr.upload){ // check if upload property exists myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // for handling the progress of the upload } return myXhr; }, //Ajax events success: postPhoto, error: function(){ alert('error'); }, // Form data data: (formData, fileData), //Options to tell JQuery not to process data or worry about content-type cache: false, contentType: false, processData: false });//end ajax }); */ });//end ready function postSuccess(data, textStatus, jqXHR){ //console.log(data); //$('#close').click(); if (data.indexOf("