我必须对Microsoft登录服务(在线共享点)进行POST,该服务会在响应中返回2个cookie,这些cookie可以用于数据请求。
但是,它返回了302(临时移动)消息,并尝试重定向到无效页面,这使ajax请求失败了,并跳至“错误”部分——尽管第一个请求具有有效的和正确使用了我可以使用的响应数据。
function getFedAuthCookies(token)
{
$.support.cors = true; // enable cross-domain query
$.ajax({
type: 'POST',
data: token,
url: "https://mysharepoint.sharepoint.com/_forms/default.aspx?wa=wsignin1.0", //loginUrl,
contentType: "application/json;odata=verbose", //'application/x-www-form-urlencoded',
dataType: 'json',
headers: {
"Accept": "application/json;odata=verbose"
},
// dataType: 'html', // default is OK: Intelligent Guess (xml, json, script, or html)
success: function (data, textStatus, result) {
alert("WORKED");
},
error: function (result, textStatus, errorThrown) {
alert("FAILED");
reportError(result, textStatus, errorThrown);
}
});
}
这是在浏览器开发者控制台(“网络”面板)中的外观:https://i.stack.imgur.com/sBLi8.png。
如何在第一个具有正确数据和302消息的请求时停止?