我的客户端有一个Web服务API,我必须首先连接到一个有效载荷的用户名和密码才能获得SecurityToken,然后使用此SecurityToken作为为所有以下API调用发送的标头的一部分,所以我是想知道如何使用JQuery $ .ajax方法来做到这一点。任何例子都非常感谢。JQuery网络服务授权
以下是我在验证到目前为止已经试过,但它始终是在响应返回了错误,所以我不知道这是否是正确的:
$(document).ready(function(){
$.ajax
({
type: "POST",
url: "http://portal.domainname.com/auth",
dataType: 'json',
async: false,
data: '{"Login : [email protected]", "Password : test"}',
success: function(){
alert('Success');
},
error: function(xhr, error){
console.debug(xhr); console.debug(error);
}
});
});
问题与上面的代码是,它总是返回200个OK状态,但令牌从来没有响应
你尝试过什么?那里有大量的'.ajax()'教程。这看起来很直接 – tymeJV
@tymeJV对不起在原始问题中添加它。我刚刚在上面添加了它。但我总是得到200 OK状态,没有任何反应,换句话说,令牌永远不会返回 – MChan