0
다른 포커 사이트에서 몇 명의 플레이어가 플레이하고 있는지 웹 사이트에 표시하고 싶습니다. This link은 JSON (tournaments.summary.players)에서 필요한 데이터를 제공합니다. .getJSON 요청을 사용하지만 데이터를 검색하지 못하는 것 같습니다. 여기 스크립트 사용된다. 당신이 당신의 콘솔에서 보면외부 사이트의 json 데이터를 추출하십시오.
// url used to get the JSON data
var pkrStats = "http://www.psimg.com/datafeed/dyn_banners/summary.json.js";
$.getJSON(pkrStats, function (json) {
// Set the variables from the results
var playersN = json.tournaments.summary.players;
console.log('Total players : ', playersN);
// Set the table td text
$('#players').text(playersN);
});
// Caching the link jquery object
var $myLink = $('a.myLink');
// Set the links properties
$myLink.prop({
href: pkrStats,
title: 'Click on this link to open in a new window.'
}).click(function (e) {
e.preventDefault();
window.open(this.href, '_blank');
});
body {
font-size: 75%;
font-family:"Segoe UI", Verdana, Helvetica, Sans-Serif;
}
#body {
clear: both;
margin: 0 auto;
max-width: 534px;
}
table {
border-collapse: collapse;
border-spacing: 0;
margin-top: 0.75em;
border: 0 none;
margin-top:35px;
}
#body td {
padding:15px 30px 15px 10px;
}
#body tr td:nth-child(1) {
font-weight:bold;
}
#address {
width:400px;
}
<div id="body">
<hr/>
<table border="1">
<tr>
<td>Url:</td>
<td><a class="myLink">json.js</a>
</td>
</tr>
<tr>
<td>Users playing:</td>
<td id="players"></td>
</tr>
</table>
</div>
내가 확실 해요,하지만이 JSONP/CORS 지원 요청을하지해야합니까? – gustavohenke