我试图在ASPX页面中运行这段代码 -
var username = ""*******";
var password = ""*******";
var vault = "*******";
var getToken = function (username , password , vault) {
// Request an encrypted token with the login information.
$.ajax ({
url: "http://example.org/REST/server/authenticationtokens.aspx",
type: "POST",
dataType: "json",
contentType : "application /json",
data: JSON.stringify ({ Username: username , Password: password ,
VaultGuid: vault }),
success: processToken
});
};
var processToken = function (token) {
// Set the header.
$.ajaxSetup ({ headers: { "X- Authentication " : token.Value } });
};
但是当我检查processToken的值时,我总是得到这个
function (token) {// Set the header.$.ajaxSetup({ headers: { "X- Authentication ": token.Value} });
};
为什么不实施?我知道我的URL和凭据是正确的。
答案 0 :(得分:0)
如果您的data:{ Username: username , Password: password , VaultGuid: vault }
为{{1}},那么您也不需要对数据进行字符串输入,只需
{{1}}
(即传递一个对象)你可能编码json两次