我在創建crowdfunder網頁的過程中,要創建一個顯示當前進度的儀表板:http://hyve.me/crowdfunder訪問各種Web服務使用Javascript
這裏是JavaScript的使用:
<script type="text/javascript">
// Facebook Likes
$.getJSON("https://graph.facebook.com/?ids=hyve.me", function (response) {
$("#facebooklikes").text(response["hyve.me"].likes);
});
// registered Users
$.ajax({
type: 'GET',
url: 'http://www.hyve.me/usercount',
dataType: 'JSON',
success: function (response) {
$("#usercount").text = response;
}
});
// days left
jQuery(document).ready(function($) {
today = new Date();
deadline = new Date("October 31, 2013");
msPerDay = 24 * 60 * 60 * 1000 ;
timeLeft = (deadline.getTime() - today.getTime());
$("#countdown").text(Math.floor(timeLeft/msPerDay));
});
// progress bar for shares
$.getJSON("https://api-public.addthis.com/url/shares.json?url=http%3A%2F%2Fwww.hyve.me%2Fcrowdfunder%2F", function (response) {
var mentions = response.shares;
document.getElementById("myProgressBar_Success").setAttribute('style', "width: " + (mentions/6).toString() + "%;");
document.getElementById("myProgressBar_Warning").setAttribute('style', "width: " + ((600 - mentions)/6).toString() + "%;");
});
</script>
和這裏是儀表盤的HTML:
<div class="span8 offset2">
<div class="row-fluid statistics">
<div class="span4"><div class="linediv-l"><h3 id="facebooklikes">0</h3><p>FB <i class="icon-thumbs-up"></i></p></div></div>
<div class="span4"><div class="linediv-c"><h3 id="usercount">0</h3><p>Hyve-Users</p></div></div>
<div class="span4"><div class="linediv-r"><h3 id="countdown">0</h3><p>days left</p></div></div>
</div>
</div>
<div class="row-fluid">
<div class="span10 offset1">
<div class="thermometer progress active">
<div class="bar bar-success" style="width: 50%;" id="myProgressBar_Success"></div>
<div class="bar bar-warning" style="width: 50%;" id="myProgressBar_Warning"></div>
</div>
</div>
</div>
現在我有一些問題:
- 在Chrome(v29)和Firefox(v23)中正確顯示Facebook讚的數量,但在Internet Explorer(v9)中無法正常顯示 - 有關如何使此瀏覽器獨立的任何想法?
- 只有當我在同一個域(hyve.me)時,註冊用戶的數量纔有效;因此,我只能在生產環境中進行測試,而不能在開發環境(AWS)或分級環境(heroku.com)上進行測試 - 如何解決此問題?
- 進度條並未根據addthis.com的數據進行更新 - 爲什麼getJSON()與Facebook-Graph協同工作,而不是使用AddThis的Web服務?
這是我在Stackoverflow的第一個問題,我花了最近2天找到答案。也許這裏的某個人可以指點我正確的方向。
在此先感謝!
-hristoph
歡迎!你可能需要在你的網站上修改措辭。我幾乎不是語法專家,但措辭似乎不對。對於數字2,您可以通過調整您的主機文件輕鬆模仿。你也可以考慮發佈多個問題,而不是一個三個。 –
我的母語不是英語,我知道我並不完美。現在我已經在背景段落中更改了一個句子。任何其他提示都非常感謝! – user2723097