Javascript 使用jqueryajax的文件上传程序
我想使用jQuery上传文件,但我得到一个异常,在Javascript 使用jqueryajax的文件上传程序,javascript,jquery,html,forms,ajaxform,Javascript,Jquery,Html,Forms,Ajaxform,我想使用jQuery上传文件,但我得到一个异常,在$('#myFile').ajaxForm({ HTML <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> <script src="jquery-1.11.1.min.js"></script> <script src="x.js"></scri
$('#myFile').ajaxForm({
HTML
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script src="jquery-1.11.1.min.js"></script>
<script src="x.js"></script>
</head>
<body>
<form enctype="multipart/form-data" action="/FileUploadUI5/upload"
method="POST" id="myFile">
<input type=file name=upfile><br> <input type="submit"
name="Upload" value="Upload" id="ubutton" />
</form>
</body>
</html>
我相信发送文件在纯jquery中是不可用的; 或 第一个是非常令人印象深刻的,我能够做到这一点在任何时间和视觉进度指标和能力,使用网络摄像头的图像是惊人的 我认为,你可以在这里找到更多的主题:
希望有帮助:-)您是否正确包含了此插件的JS文件?是否
x.JS
您的AjaxForm
插件副本?我已经在控制台中包含了jquery nd,我打印了jquery.fn.jquery;结果是“1.11.1”…因此我认为它包含正确。您也不需要“$”(“\ubutton”)。单击(…`as'#ubutton'已经是'#myFile'表单中的一个提交按钮。而且,为什么您有一个空的beforeSend函数?您还需要从这里下载并包含jquery表单插件
$(document).ready(function() {
$(function() {
$('#myFile').ajaxForm({
beforeSend : function() {
},
uploadProgress : function(event, position, total, percentComplete) {
alert(position + "|" + total + "|" + percentComplete);
},
complete : function(xhr) {
// status.html(xhr.responseText);
}
});
});
$('#ubutton').click(function(e) {
$('#myFile').submit();
});
});