1
當我呼叫 「$(」#progressbar「)。progressbar({」計算機告訴我「進度條不是功能」 也進度barr甚至不顯示在屏幕上 使用Visual Studio 2015年prograo在ASP .NET框架4.5jquery進度欄不是功能
<script src="jquery-ui.js"></script>
<script src="jquery-2.1.4.js"></script>
<link href="jquery-ui.css" rel="stylesheet" />
<script >
$(document).ready(function() {
$("#Button1").click(function (evt) {
var xhr = new XMLHttpRequest();
var data = new FormData();
var files = $("#FileUpload1").get(0).files;
for (var i = 0; i < files.length; i++) {
data.append(files[i].name, files[i]);
}
xhr.upload.addEventListener("progress", function (evt) {
if (evt.lengthComputable) {
var progress = Math.round(evt.loaded * 100/evt.total);
$("#progressbar").progressbar("value", progress);
}
}, false);
xhr.open("POST", "UploadHandler.ashx");
xhr.send(data);
$("#progressbar").progressbar({
max: 100,
change: function (evt, ui) {
$("#progresslabel").text($("#progressbar").progressbar("value") + "%");
},
complete: function (evt, ui) {
$("#progresslabel").text("File upload successful!");
}
});
evt.preventDefault();
});
});
</script>
體
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Select File(s) to Upload :"></asp:Label>
<br />
<br />
<asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Upload" />
<br />
<br />
<div id="progressbar" class="progressbar">
<div id="progresslabel" class="progressbarlabel">zzz</div>
</div>
</form>
jQuery的用戶界面可能會需要的jQuery後纔會被載入。 – turbopipp