gpt4 book ai didi

Blueimp jQuery 多文件上传插件 $(this).fileupload() 不是函数

转载 作者:行者123 更新时间:2023-12-02 06:18:50 25 4
gpt4 key购买 nike

我在 struts 框架中为我的 Web 应用程序使用 blueimp jQuery 插件进行多个文件上传,但问题是文件上传处理程序未由 jQuery 初始化。我得到 $('#fileupload').fileupload 不是函数。谁能帮我弄清楚我哪里出错了。

`<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link href="css/jquery.fileupload-ui.css" rel="stylesheet" type="text/css"/>
<link href="css/jquery.fileupload-ui-noscript.css" rel="stylesheet" type="text/css"/>
<link href="css/style.css" rel="stylesheet" type="text/css"/>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/jquery.iframe-transport.js"></script>
<script src="js/main.js"></script>
<script src="js/jquery.postmessage-transport.js"></script>
<script src="js/jquery.ui.widget.js"></script>
<script src="js/jquery.fileupload.js"></script>
</head>
<style type="text/css">
.bar {
height: 18px;
background: green;
}
</style>
<head>
<body>
<form id="fileupload" action="testAction.do?operation=uploadImages" method="POST" enctype="multipart/form-data">
<noscript><input type="hidden" name="redirect" value="http://blueimp.github.io/jQuery-File-Upload/"></noscript>
<div class="row fileupload-buttonbar">
<div class="span7">
<span class="btn btn-success fileinput-button">
<i class="icon-plus icon-white"></i>
<span>Add files...</span>
<input type="file" name="files[]" multiple>
</span>
<button type="submit" class="btn btn-primary start">
<i class="icon-upload icon-white"></i>
<span>Start upload</span>
</button>
<button type="reset" class="btn btn-warning cancel">
<i class="icon-ban-circle icon-white"></i>
<span>Cancel upload</span>
</button>
<button type="button" class="btn btn-danger delete">
<i class="icon-trash icon-white"></i>
<span>Delete</span>
</button>
<input type="checkbox" class="toggle">
<span class="fileupload-loading"></span>
</div>
<div class="span5 fileupload-progress fade">
<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
<div class="bar" style="width:0%;"></div>
</div>
<div class="progress-extended">&nbsp;</div>
</div>
</div>
<table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
</form>
<br>

<div id="progress">
<div class="bar" style="width: 0%;"></div>
</div>

<script>
jQuery(function () {
jQuery('#fileupload').fileupload({
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
}
});
});
</script>
</body>
</html>`

最佳答案

您必须确保以正确的顺序加载所有脚本文件:

jquery.ui.widget.js
jquery.iframe-transport.js
jquery.fileupload.js

就在你关闭 body 标签之前。

此外,使用浏览器检查器查看脚本是否正在加载。

关于Blueimp jQuery 多文件上传插件 $(this).fileupload() 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17403239/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com