我正在使用 cURL api 调用,并将其转换为 ajax,但它不起作用。有任何想法吗?
curl -v -X POST -H "Content-Type: application/json" -H "Accept: application/json" --user user:pass https://i.am.web/123456789/events -d "{\"name\": \"Marcus0.1\",\"start\": 500000,\"end\": 1361640526000}"
.
$.ajax({
type: 'POST',
url: 'https://i.am.web/123456789/events',
dataType: 'application/json',
accept: 'application/json',
async: false,
username: 'user',
password: 'pass',
data: {
"name": "Marcus0.3",
"start": 500000,
"end": 1361640526000
},
success: function(){alert('DONE!');},
error:function(error){alert(error)},
});
alert("ENDING API MAIN FUNCTION")
铬错误:
http://i.am.website/123456789 & POST & 401 未授权 & text/html & query.min/js:2 脚本