TypeError:$(...)。dropzone不是函数 [英] TypeError: $(...).dropzone is not a function

查看:75
本文介绍了TypeError:$(...)。dropzone不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的django应用中使用dropzone,我遵循了许多示例,但没有一个示例对我有用
您能帮我吗

i'm triying to use dropzone in my django app, I followed many examples but none of them worked for me can you please help me

js代码:

     <script src="https://code.jquery.com/jquery-1.12.4.min.js"
integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
      <link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.css" rel="stylesheet" type="text/css" />
      <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.3.0/min/dropzone.min.js" type="text/javascript"></script>
      <script type="text/javascript">
      Dropzone.autoDiscover = false;
        $(document).ready(function(){
            $('#myDropzone').dropzone({
                url: "{% url 'dashboard/import' %}",
                addRemoveLinks: true,
                success: function (file, response) {
                    console.log("Successfully uploaded");
                },
                error: function (file, response) {
                    console.log("something goes wrong");
                }
            });
     });
     </script>

HTML代码:

<form action="{% url 'dashboard/import' %}" class="dropzone">
     {% csrf_token %} 
</form>

我遇到了TypeError:$(...)。dropzone不是函数

I've got an TypeError: $(...).dropzone is not a function

推荐答案

通过查看相关的javascript文件,函数名称dropzone以大写字母开头。因此,尝试使用大写的函数,如下所示:

By looking at the related javascript file, the function name dropzone starts with uppercase letter. So try the function with uppercase as shown below:

 $(document).ready(function(){
        $('#myDropzone').Dropzone({
            url: "{% url 'dashboard/import' %}",
            addRemoveLinks: true,
            success: function (file, response) {
                console.log("Successfully uploaded");
            },
            error: function (file, response) {
                console.log("something goes wrong");
            }
        });

这篇关于TypeError:$(...)。dropzone不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆