我想从jquery获取完整的下载URL。这是原始代码,它将视频转换为mp3文件然后放回下载文件的URL。但是,我想回复完整的下载URL到ID结果,而不是强迫访问者下载mp3文件。
我该怎么做?我用jquery转储。
<script>
var App = {
init : function(){
$(document).on('submit', "#downloadVideo", App.videoDownload);
},
videoDownload : function(e){
e.preventDefault;
var url = $(this).find('[name=address]');
var btn = $('#btn-submit-form');
if(!btn.attr('disabled') !== undefined){
$.ajax({
url : 'protected/getVideo.php',
data : { address : url.val() },
type : 'POST',
dataType : 'json',
beforeSend : function(){
btn.button('loading');
},
success : function(data){
if(data.success === true){ // get the mp3 and put it into folder musics
App.videoRedirect(data.url);
//$('#results').html(data.url);
}else{
alert('Url cannot be empty');
}
}
}).always(function () {
btn.button('reset');
url.val('');
});
}
return false;
},
videoRedirect : function(music){
window.location.href = 'musics/' + music;
}
};
$(App.init);
</script>
&#13;
<div class="alert alert-danger" id="results">
</div>
<!-- I want to display the url and name to ID results. Right now it just shows the name, not url to download -->
&#13;
我应该使用这个插件:
http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/
如果是,我该如何实施呢?