通过使用此URL http://myserveripaddress/finesse/api/User/,凭据是myusername和mypassword,我应该通过单击代理按钮来获取代理的XML响应,但是这里面临着没有“ Access-Control-Allow-Origin”标头的问题存在于请求的资源上。因此,不允许访问原始“空”。这是我的代码
here is the my code
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
</head>
<body>
<button id="agent">agent</button>
<script type="text/javascript">
$(document).ready(function() {
$('#agent').click(function() {
$.ajax({
type: "GET",
crossDomain: true,
xhrFields: {
withCredentials: true
},
url: 'http://myserveripaddress/finesse/api/User/55022',
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', "Basic " + btoa("myusername", "mypassword"));
},
dataType: "xml",
success: function(data) {
alert(data);
},
error: function(err) {
alert("err")
}
});
});
});
</script>
</body>
</html>