O2OA如何解决$.ajax的跨域问题
第三方系统调用,服务管理中的配置的接口地址时,$.ajax中的参数需要怎么传,请求头里需要什么?跨域问题如何解决?为什么接不到参数呢?
发送成功了,为什么没有消息提示呢?
ERF 发表于 2022-5-5 13:48
发送成功了,为什么没有消息提示呢?
获取当前时间下的token就没问题了
综上问题基本解决,谢谢
本帖最后由 论坛管理员 于 2022-5-6 10:27 编辑
您好,昨天的帖子,消息没有发送成功的问题,管理员这边昨天也测试了,已经提交给研发,研发还没有回复,所以帖子就没回。
请问您是怎么解决的呢?
-----------------------
管理员去确认了,接口发起的文档是有消息的,只是存储在后端的数据表里,前端PC上不会弹出。
论坛管理员 发表于 2022-5-6 10:14
您好,昨天的帖子,消息没有发送成功的问题,管理员这边昨天也测试了,已经提交给研发,研发还没有回复,所 ...
您好,我一开始用的token是从之前请求中copy来的,这样直接写在$.ajax的headers中,发送请求,在用户页面中是没有消息提示的。但是后来我在发起请求之前,先获取token,把当前获取的token传入,然后就有消息提示了
<script type="text/javascript" language="JavaScript">
let token = "";
function getToken() {
let client = "HR";
let key = "12345678";
let credential = "001";
$.ajax({
url: "http://127.0.0.1:20020/x_organization_assemble_authentication/jaxrs/sso/encrypt/client/" + client+ "/key/" + key+ "/credential/" + credential,
headers: {
"Content-Type": "application/json; charset=UTF-8"
},
type: 'GET',
data: {},
dataType: "json",
traditional: true,
success: function (res) {
console.log(res);
console.log("res.data的参数类型" + typeof res.data);
console.log("res.data.token的参数类型" + typeof res.data.token);
token = res.data.token;
console.log(token);
}
})
}
function test(){
$.ajax({
url:"http://127.0.0.1/x_program_center/jaxrs/invoke/assignCreate/execute",
headers: {
"Authorization": token,
"Content-Type": "application/json; charset=UTF-8",
"x-token": token
},
type: "POST",
data: JSON.stringify({
"identity" : "001@2010200_001@I",
"title" : "接口调用--收文标题(我成功了)",
"data" : {
"receivedFileNo" : "我又发了个待办222222200000"
},
"application": "c3aab5f8-7062-4e93-97a3-d88e6a6bdd64",
"process": "4fe9b22d-e3d3-49d2-99b2-d80ffc28d899",
"processing": true
}),
dataType: "json",
traditional: "true",
async: false,
success: function(res) {
console.log(res);
console.log("res.data的参数类型" + typeof res.data);
console.log("res.data.value的参数类型" + typeof res.data.value);
console.log("res.data.value的值" + res.data.value);
if(res.data.value && typeof res.data.value == 'string') {
console.log(JSON.parse(res.data.value))
}
}
})
}
</script>
我先调用getToken()方法获取token,再执行test()方法,回到页面上去看,就有消息提示了。也是误打误撞出来的。不知道是不是正解。
噢噢,我转给研发人员看一看:)
页:
[1]