gpt4 book ai didi

javascript - 使用 AjaxUpload 库时出现安全错误 : The operation is insecure.

转载 作者:行者123 更新时间:2023-11-28 01:09:46 25 4
gpt4 key购买 nike

我正在使用 Valums AjaxUpload 库上传图像,突然收到 SecurityError: The operation is insecure. 错误。除了一点 html 之外,没有任何变化(我已向文本输入添加了 value 属性,并向 img 标记添加了 src)。

我看过一些答案thisthis但我不确定这些是否适用,因为这以前有效,但现在不行了。我正在从我一直在的同一目录上传文件。

还有其他人遇到过此警告随机出现的问题吗?脚本运行的域不使用 SSL,因此我可以看出此错误是 http/https 问题的任何原因,特别是因为没有任何 JS 代码发生更改。

编辑:错误似乎在这一行抛出

$('input[name=image]').val(response.data.url);

我会做一些挖掘,看看是否能找出原因

这是我的上传功能的 JS

new AjaxUpload( $('#imageUpload'),{

action: '/sivactivities/ajax/upload',
name: 'image',
data: {
'itemId' : DataBridge.itemId
},

onSubmit : function(file, ext){
// If you want to allow uploading only 1 file at time,
// you can disable upload button
this.disable();


},
onComplete: function(file, response){

// enable upload button
this.enable();

response = SIV.decode(response);
console.log(response);
DataBridge.imageHeight = response.data.height;
DataBridge.imageWidth = response.data.width;
DataBridge.thumbSrc = response.data.url;
$('#image-upload-load').hide();
$('input[name=image]').val(response.data.url);
$('#uploadedImg').attr('src', response.data.url);
}
});

和 HTML

<div class="formKey">Image</div>
<div class="formVal">
<p>Please make sure this image is 246 x 164</p>
<div style="display:inline-block; width:150px;float:left;">
<div class="upload-button"><a class="smaller-button imageUpload" id="imageUpload" href="#"/><span></span>BROWSE</a></div>
<div style="height: 75px;" id="divFileProgressContainer"></div>
<div class="form-loading hide" id="item-upload-load">
<img src="/open/img/loading-indicator.gif" alt="loading"/>
<input type="hidden" name="image" />
</div>
</div>

<div style="display:inline-block; width:300px;">
<img id="uploadedImg" />
</div>
</div>

最佳答案

经过进一步调试后,我发现我正在尝试更新文件输入的值,而不是图像(两个元素都有 ID image)。

This answer让我检查了 ID,最终解决了我的问题。

关于javascript - 使用 AjaxUpload 库时出现安全错误 : The operation is insecure.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24608757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com