<a class="replace" params="1">Replace</a>
<div id="replace" class="ui-dialog-content ui-widget-content">
<form action="/v5/files/doc" enctype="multipart/form-data" class="form-horizontal" role="form" id="FileDocForm" method="post" accept-charset="utf-8">
<div class="input file">
<label for="FileFile">New File</label><input type="file" name="data[File][file]" id="FileFile">
</div>
</form>
</div>
<script type="text/javascript">
$(document).ready(function () {
var files;
$('.replace').click(function(){
$('#replace').data('params',$(this).attr('params')).dialog('open');
});
$('#replace').dialog({
modal : true,
autoOpen : false,
autoResize : true,
width : 'auto',
height : 'auto',
buttons : {
'Submit' : function (){
var data = new FormData($('#replace form')[0]);
$.ajax({
type : 'POST',
data:data,
processData:false,
contentType: false,
url :'replaceDoc/'+$('#replace').data('params'),
success : function(data){
location.reload();
}
});
},
'Cancel' : function (){
$(this).dialog('close');
}
}
});
});
</script>
Wednesday, October 15, 2014
Jquery Submit File via dialog
Labels:
javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment