AjaxUpload:为什么我必须点击两次?
下面的代码使用 AjaxUpload.2.0.min.js 将文件上传到服务器,
但是您需要多次单击操作系统窗口(在其中选择要上传的文件的位置)的“添加文件”按钮才能显示,而不是只需点击一次。
另外,如果您在链接中单击一次,然后将鼠标移出红色区域并单击(#upload_files 之外),最后单击链接,它就可以工作,操作系统窗口将打开..但是为什么这样做我必须这样做吗? AjaxUpload 最初不会绑定在 .livequery 调用中吗?那么,我该如何绑定呢?
请注意这一点,即第一次单击鼠标时显示的操作系统窗口。其余的编程在我的服务器上运行良好。
.js 上传到 github 是为了使代码易于测试,但在实际情况下它们在我的机器中。
多谢
<head>
<style>
#upload_files{color: #fff; background:#F32201; border:1px solid #7E9DB9; padding:2px;}
</style>
<script type="text/javascript" src="https://gist.github.com/raw/6dd585079502f138d87e/7c243080233761859937d52195b670602731a379/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="https://gist.github.com/raw/eeb2fe78f63ab80b626d/5be66e749b19fbb5b7c8814bf72a98c083f2aaaf/jquery.livequery.min.js"></script>
<script type="text/javascript" src="https://gist.github.com/raw/826bff2445c8533dd7fc/797734455959ef27796b6770c95a7b39049ae6e9/AjaxUpload.2.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
function uploadFiles(){
new AjaxUpload('#upload_files', {
action: 'whereToUploadInServer.php',
});
}//end uploadFiles
$("#upload_files").livequery("click", function(e){
e.preventDefault();
uploadFiles();
//debugger ;
});
}); //end document ready
</script>
</head>
<body>
<div><a href="#" id="upload_files">Add File</a></div> <br>
</body>
The code below uploads files to the server using AjaxUpload.2.0.min.js
But you need to click several times on the “Add File” button for the OS window (where to pick the file you want to upload) to show, instead of clicking just once.
Also, if you click once in the link and then you move the mouse out of the red area and click (out of #upload_files), and last you click back in the link, it works, the OS window opens .. but why do I have to do this? Is that AjaxUpload will not be initially bound in the .livequery call? then, how do I bound it?
Please focus on this, on the OS window to show with the first click of the mouse. The rest of the programming it's working fine in my server.
The .js are uploaded into github to make the code easy to test, but in the real case they are in my machine.
Thanks a lot
<head>
<style>
#upload_files{color: #fff; background:#F32201; border:1px solid #7E9DB9; padding:2px;}
</style>
<script type="text/javascript" src="https://gist.github.com/raw/6dd585079502f138d87e/7c243080233761859937d52195b670602731a379/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="https://gist.github.com/raw/eeb2fe78f63ab80b626d/5be66e749b19fbb5b7c8814bf72a98c083f2aaaf/jquery.livequery.min.js"></script>
<script type="text/javascript" src="https://gist.github.com/raw/826bff2445c8533dd7fc/797734455959ef27796b6770c95a7b39049ae6e9/AjaxUpload.2.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
function uploadFiles(){
new AjaxUpload('#upload_files', {
action: 'whereToUploadInServer.php',
});
}//end uploadFiles
$("#upload_files").livequery("click", function(e){
e.preventDefault();
uploadFiles();
//debugger ;
});
}); //end document ready
</script>
</head>
<body>
<div><a href="#" id="upload_files">Add File</a></div> <br>
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,根据 Github 上的文档,ajaxupload 组件目前尚未完全运行。作者建议使用新的 qq.FileUploader 插件。
下面的示例在单击 div 元素后立即打开文件对话框。
jsFiddle 示例
希望有帮助。
As far as I can tell, the ajaxupload component is not fully operational at this time according to the docs on Github. The author suggests using the new qq.FileUploader plugin instead.
Here's an example that brings up the file dialog immediately after clicking the div element.
jsFiddle example
Hope it helps.