我正在尝试在我的网站上添加视频文件上传功能:
我正在关注此处发布的示例:http://davidsonsousa.net/en/post/how-to-upload-a-file-using-mvc-3-and-ajax
我已经在我的MVC项目中包含了所有必需的库。在我看来,我包括了以下标题:
<head>
<title>Videos </title><!-- Bootstrap core CSS -->
<link href="~/Scripts/jquery-lib/jquery.fileupload.css" rel="stylesheet" />
<script src="/Scripts/jquery-lib/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery-lib/jquery.ui.widget.js" type="text/javascript"></script>
<script src="/Scripts/jquery-lib/bootstrap.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery-lib/jquery.fileupload.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#fileupload').fileupload({
dataType: 'json',
url: '/Videos/UploadVideoFile/?isrc=' + 'HGTGHTGTYTGT',
autoUpload: true,
done: function (e, data) {
$('.file_name').html(data.result.name);
$('.file_type').html(data.result.type);
$('.file_size').html(data.result.size);
}
}).on('fileuploadprogressall', function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('.progress .progress-bar').css('width', progress + '%');
});
});
</script>
</head>
当我加载网页时,我收到以下错误:
未捕获类型错误undefined不是函数 在上传脚本中指向此部分:$('#fileupload')。fileupload({
我也得到了错误:
Uncaught TypeError: undefined is not a function add:96
Uncaught ReferenceError: jQuery is not defined jquery.ui.widget.js:18
Uncaught ReferenceError: jQuery is not defined bootstrap.min.js:6
Uncaught TypeError: Cannot read property 'support' of undefined jquery.fileupload.js:32
Uncaught ReferenceError: $ is not defined add:95
Uncaught TypeError: Cannot read property 'support' of undefined jquery.fileupload.js:32
Uncaught ReferenceError: $ is not defined
答案 0 :(得分:1)
似乎没有加载jQuery。打开浏览器的调试器(F-12)并查看NETWORK选项卡。重新加载页面并查找404错误。你可能走错路。