0
我做了自定義的共享按鈕,並想添加Pocket計數它們。如何從袖珍按鈕(使用jQuery)獲取袖珍計數器?
如果你打開這個鏈接https://widgets.getpocket.com/v1/button?count=vertical&url=http://google.com在瀏覽器中,你會看到櫃檯袖珍的按鍵(前。網址是google.com)。
很簡單的html文件:
<html><head>
<link rel="stylesheet" type="text/css" href="https://d7x5nblzs94me.cloudfront.net/v1/c/button.css?v=6">
<script type="text/javascript" src="https://d7x5nblzs94me.cloudfront.net/v1/j/shared.js?v=2"></script>
<style type="text/css"></style></head>
<body>
<div class="widget vertical pocket center">
<a id="btn">
<!--
Please do not scrape this for the Pocket count.
It is not relible for you to use and will likely change.
Contact us at [email protected] for an official API.
Thanks!
-->
<span><em id="cnt">126775</em><i></i><u></u></span>
<b></b>
</a>
</div>
<script type="text/javascript">
var POCKET_DOMAIN = 'getpocket.com';
var iLi = true;
var btnData = {"mode":"viapocketbutton","ct":"b607befed1e75f78567281514cae33db78cbcab9","ctn":"ed82217ee621d17ee56ca091cd836e96149b7921","label":"pocket","count":"vertical","src":"","url":"http:\/\/google.com"};
</script>
<script type="text/javascript" src="https://d7x5nblzs94me.cloudfront.net/v1/j/button.js?v=5"></script>
</body></html>
如何使用jQuery.ajax()
或別的東西(JS)解析這個袖珍數(放在<em id="cnt">...</em>
)?
你的意思是這個http://api.jquery.com/load/?這是jQuery函數不跨域查詢工作,並在控制檯''的XMLHttpRequest出現錯誤無法加載https://widgets.getpocket.com/v1/button?count=vertical&url=http://google.com。在「訪問控制允許來源」報頭包含多個值...'' – Platon
我發現這個解決方案CORS:http://stackoverflow.com/a/17299796/5334651並以http寫代碼:// anyorigin。 com服務。 – Platon
哇...如果我發送回答顯示此消息:''我們不再接受這個帳戶的答案.'',順便說一句.. :( – Platon