AjaxUpload:为什么我必须点击两次?

发布于 2024-10-05 09:00:03 字数 1619 浏览 7 评论 0原文

下面的代码使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉月流沐 2024-10-12 09:00:03

据我所知,根据 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文