gpt4 book ai didi

javascript - Ajax POST FormData 无法在 https(安全链接)中工作

转载 作者:行者123 更新时间:2023-12-03 01:24:57 25 4
gpt4 key购买 nike

我们正在尝试将图片上传到我们的服务器。它在 http 网站中运行良好,但在 https 网站中运行不佳。

它抛出以下内容:enter image description here 无法加载资源:服务器响应状态为 500(内部服务器错误)这是用于ajax的代码

Java 脚本

function fnTest(){
var iTaskID = $("#hdnCurTaskID").val();
var files = $("#TaskImg")[0].files;
if (files.length > 0) {
if (files.length > 3) {
alert("Maximum 3 files Allowed");
return;
}
if (typeof FormData == "undefined") {
var postdata = [];
for (var i = 0; i < files.length; i++) {
postdata.push("UploadedFile", files[i]);
}
postdata.push("TaskID", iTaskID);
}
else {
var postdata = new FormData();
for (var i = 0; i < files.length; i++) {
postdata.append("UploadedFile", files[i]);
}
postdata.append("TaskID", iTaskID);
}
$.ajax({
type: "POST",
url: "TaskStatus.asmx/UploadExecTaskPic",
contentType: false,
processData: false,
async: false,
responseType: "json",
data: postdata,
success: function (result) {
var MaxFile = GetSessionValuecurrent(iTaskID);
if (MaxFile == "MaxFile") {
alert("Maximum 3 Files only Allowed to Upload");
}
else {

$("#TaskImg").val("");
$("#TaskImg").replaceWith($("#TaskImg").clone());
DoCloseFileSelector();
DoShowTaskImages(iTaskID, '');
}
},
error: function () {
alert("Upload Error");
}
});
}
}

网络方法:

[WebMethod(EnableSession = true)]
public string UploadExecTaskPic()
{
string sResult = string.Empty;
return sResult;
}

最佳答案

我在 Google 搜索中发现了此信息

FIX Request format is unrecognized for URL unexpectedly ending in

Add the following to web.config since GET and POST are disabled by default in ASP.NET 2.0 and greater:

<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>

关于javascript - Ajax POST FormData 无法在 https(安全链接)中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51592879/

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