jQuery无法在ASPX中运行

时间:2018-12-19 00:52:36

标签: jquery asp.net sharepoint-2010 cloudinary

我尝试使用以下代码在.aspx页中使用Cloudinary JQuery SDK:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js" type="text/javascript"></script>
<script src="https://cdn.rawgit.com/cloudinary/cloudinary_js/master/js/jquery.ui.widget.js" type="text/javascript"></script>
<script src="https://rawgit.com/cloudinary/cloudinary_js/master/js/jquery.iframe-transport.js" type="text/javascript"></script>
<script src="https://rawgit.com/cloudinary/cloudinary_js/master/js/jquery.fileupload.js" type="text/javascript"></script>
<script src="https://rawgit.com/cloudinary/cloudinary_js/master/js/jquery.cloudinary.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        console.log("Ready!");
        $.cloudinary.config({
            cloud_name: 'MYCLOUD'
        })

        $('.cloudinary_fileupload').unsigned_cloudinary_upload('MYUNSIGNEDUPLOADPRESET', {
            cloud_name: 'MYCLOUD',
            tags: 'browser_uploads'
        }, {
            multiple: true
        })
        .bind('cloudinarydone', function(e, data) {
            // inspect data.result for return value with link to the uploaded image and more
            console.log('Upload result', data.result);
            // Create a thumbnail of the uploaded image, with 150px width
            var image = $.cloudinary.image(
                data.result.public_id, {
                    secure: true,
                    width: 150,
                    crop: 'scale'
                });
            $('.gallery').prepend(image);
        });
    });
</script>

还有

        <asp:Panel runat="server" ID="JQuery">
        <input name="file" type="file" class="cloudinary-fileupload"/>
        </asp:Panel>

不幸的是,当我选择图像时,什么也没有发生,并且上传从未完成。

谁能指出是什么原因导致JQuery脚本无法按预期运行?

1 个答案:

答案 0 :(得分:0)

问题是我在HTML中使用了错误的类名。

以下内容:

    <asp:Panel runat="server" ID="JQuery">
    <input name="file" type="file" class="cloudinary-fileupload"/>
    </asp:Panel>

应更改为:

    <asp:Panel runat="server" ID="JQuery">
    <input name="file" type="file" class="cloudinary_fileupload"/>
    </asp:Panel>