<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<title>Sample Page</title>
<script>
var summonername = "TraversTT"
var api_key1= "******"
var headers1 = {
'Access-Control-Allow-Origin': '*',
'Origin': "https://developer.riotgames.com",
'Accept-Charset': "application/x-www-form-urlencoded; charset=UTF-8",
'X-Riot-Token': "*****",
'Accept-Language': "en-US,en;q=0.9",
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
}
var settings = {
"async": true,
"type": "POST",
"url": "https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/"+summonername+"?api_key="+api_key1,
"headers": headers1,
"dataType": 'json',
"data": 'dataTest',
};
$.ajax(settings).done(function (response) {
console.log(response);
});
I am getting constant errors connecting to this API and getting a response other than:
(我在连接到此API时不断出错,并且得到以下响应:)
jquery.min.js:4 Refused to set unsafe header "Origin" send @ jquery.min.js:4 ajax @ jquery.min.js:4 (anonymous) @ Riot dDragon access sample2.html:26 jquery.min.js:4 Refused to set unsafe header "Accept-Charset" send @ jquery.min.js:4 ajax @ jquery.min.js:4 (anonymous) @ Riot dDragon access sample2.html:26 jquery.min.js:4 Refused to set unsafe header "User-Agent" send @ jquery.min.js:4 ajax @ jquery.min.js:4 (anonymous) @ Riot dDragon access sample2.html:26 2jquery.min.js:4 OPTIONS https://na1.api.riotgames.com/lol/summoner/v4/summoners/by- name/TraversTT?api_key=RGAPI-1ed86c58-2eee-4e6c-85d4-3bead97e4d3b 405 (Method Not Allowed) send @ jquery.min.js:4 ajax @ jquery.min.js:4 (anonymous) @ Riot dDragon access sample2.html:26 Riot dDragon access sample2.html:1 Access to XMLHttpRequest at ' https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/TraversTT ?
(jquery.min.js:4拒绝设置不安全的标头“来源” send @ jquery.min.js:4 ajax @ jquery.min.js:4(匿名)@ Riot dDragon访问sample2.html:26 jquery.min.js :4拒绝设置不安全的标头“ Accept-Charset”发送@ jquery.min.js:4 ajax @ jquery.min.js:4(匿名)@ Riot dDragon访问sample2.html:26 jquery.min.js:4拒绝设置不安全的标头“ User-Agent”发送@ jquery.min.js:4 ajax @ jquery.min.js:4(匿名)@ Riot dDragon访问sample2.html:26 2jquery.min.js:4选项https: /// /na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/TraversTT?api_key=RGAPI-1ed86c58-2eee-4e6c-85d4-3bead97e4d3b 405(不允许使用方法)发送@ jquery.min.js: 4 ajax @ jquery.min.js:4(匿名)@ Riot dDragon访问sample2.html:26 Riot dDragon访问sample2.html:1通过' https://na1.api.riotgames.com/lol/summoner访问XMLHttpRequest / v4 / summoners /按名称/ TraversTT ?)
api_key=RGAPI-1ed86c58-2eee-4e6c-85d4-3bead97e4d3b' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.`(api_key = RGAPI-1ed86c58-2eee-4e6c-85d4-3bead97e4d3b'已被CORS策略阻止:对预检请求的响应未通过访问控制检查:没有“ Access-Control-Allow-Origin”标头存在于请求的资源上。)
I've been playing with different ways of doing this today for like 6 hours so any help available would be amazing.
(今天,我一直在用不同的方式进行此操作,大约6个小时,因此任何可用的帮助都将是惊人的。)
ask by TraversTT translate from so