var obj = {
BaseId: OrgID,
Title: title,
AccountCategoryId: AccountCategoryId,
UserId: UserId,
Content: Content,
Status: Status,
AboutExtType: AboutExtType,
ImgList: ImgList,
contentList: contentList,
Picture: Picture,
vid: vid,
};
$.ajax({
type: 'post',
url: url1,
data: obj,
headers: {
'Authorization': Authorization
},//头部参数,需要在接口项目中设置,头部可传参数名Authorization
async: false,//默认异步,true
success: function (res) {
if (res.code == '10000') {
top.layer.msg('操作成功', { icon: 1, time: 2000 });
$('#add').removeClass('layui-btn-disabled');
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);//关闭当前页
}
else {
top.layer.msg('操作失败', { icon: 2, time: 2000 });
$('#add').removeClass('layui-btn-disabled');
}
}
})
The interface is called in js, and the interface project needs to set cross-domain and request header parameters. Set the code in the Web.config of the interface project
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<httpProtocol>
<customHeaders>
<!--*代表任何人域名都可以访问,也可以可以指定那些域名可以访问,指定多个可以用“,”隔开-->
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="AuthToken, Authorization, Origin, Content-Type, Accept, X-Requested-With" />
<add name="Access-Control-Allow-Methods" value="GET, PATCH, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
<!--<handlers> 跨域时不需要加此数据,加了之后无法传递 handler
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>-->
<defaultDocument>
<files>
<add value="Index.cshtml" />
</files>
</defaultDocument>
</system.webServer>