【发布时间】:2015-10-26 00:22:49
【问题描述】:
这是我使用 javascript 的第一周,我正在尝试访问需要通过发布请求进行身份验证的 api。帖子工作正常,但我不知道如何使用 get 请求发送 cookie。
编辑2:
我把成功函数改成:
success: function(data, status, xhr);
更接近文档。从 console.log(data, status, xhr) 返回以下内容:
对象 {readyState: 4, responseText: "{"value":{"publisher":{"active":"1","publisher_id":"######"}}}", responseJSON:对象,状态:201,状态文本:“已创建”}
也许这可以为外面的人澄清一些事情?
到目前为止,这是我的代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery-2.1.4.min.js"></script>
<script>
$(function() {
$.ajax({
url: "https://publisher-api.com/1.0/Publisher/Login",
type:"POST",
data: {"username":"######","password":"@@@@@@"},
dataType: "json",
success: function(response) {
console.log(response);
}
});
$.ajax({
url: "https://publisher-api.com/1.0/Publisher(######)/Channels/RevenueReport",
type: "GET",
dataType: "json",
success: function(data) {
console.log(data);
}
});
});
</script>
</head>
<body>
</body>
</html>
【问题讨论】:
标签: javascript jquery ajax cookies