透過JS跨網域存取XML檔
為了一些安全性的因素,通常伺服器會阻擋跨網域的XML存取,當然如果你是該網站開發者,所開發的頁面應該將會被放在被認可的網域中,不會碰到這個問題,但我們在開發前期有可能會不在所屬的網域,這樣就會造成開發上的困難,不過我們可以透過Yahoo所提供的YQL查詢語法來解決這個問題,以下就是相關的說明:
若我們在自己的電腦用以下的語法去存取一個網路上的XML
<script> $(function () { var xmlSource = "http://stanley.cloudlab.tw/crossDomainXML/testXML.xml"; $.ajax({ url: xmlSource, success: function (data) { console.log(data); } }) }) </script>
很可能會出現「No Access Control Allow Origin」的訊息:
但如果套用上YQL之後
<script> $(function(){ var xmlSource = "http://stanley.cloudlab.tw/crossDomainXML/testXML.xml"; var yqlURL = [ "http://query.yahooapis.com/v1/public/yql", "?q=" + encodeURIComponent("select * from xml where url='" + xmlSource + "'"), "&format=xml&callback=?" ].join(""); $.getJSON(yqlURL, function(data){ console.log(data) }); }) </script>
可以看到已經可以抓到XML內容,這樣可以讓我們較為方便的去開發,其他詳細的使用說明可以參考Yahoo YQL Guide。
http://prednisoneall.shop/# prednisone 10mg buy online
where can i purchase zithromax online how to get zithromax zithromax capsules
cost clomid without insurance: order cheap clomid pills – can i buy generic clomid without rx
can you buy clomid without dr prescription: can i buy clomid – can i purchase clomid without prescription
zithromax purchase online zithromax over the counter canada buy zithromax 1000mg online
https://zithromaxall.com/# can you buy zithromax over the counter in canada
order augmentin 625mg online cheap – cipro 1000mg for sale baycip pills
http://prednisoneall.com/# 50mg prednisone tablet
order amoxicillin online: order amoxicillin uk – amoxicillin 500 mg without a prescription
amoxicillin 500 capsule where to buy amoxicillin pharmacy amoxicillin discount coupon
can i purchase prednisone without a prescription prednisone otc uk buy prednisone online canada
https://amoxilall.com/# buy amoxicillin online mexico
http://prednisoneall.shop/# prednisone 10mg prices
average cost of generic zithromax buy cheap generic zithromax zithromax generic price
https://prednisoneall.shop/# prednisone daily
buying cheap clomid without dr prescription: where can i buy clomid without insurance – how can i get clomid prices
apo prednisone: prednisone 20mg prescription cost – purchase prednisone
https://prednisoneall.com/# prednisone generic cost
http://amoxilall.shop/# amoxicillin 500 mg capsule
https://zithromaxall.com/# zithromax z-pak price without insurance
where can i buy amoxicillin over the counter: amoxil generic – amoxicillin 500 tablet
prednisone pills 10 mg prednisone without prescription prednisone 2.5 mg daily
Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.
Официальный сайт Гама казино
can i buy generic clomid online how to buy cheap clomid no prescription can i order clomid online
amoxicillin tablets in india: amoxicillin azithromycin – amoxicillin 500mg
cheap prednisone 20 mg 5 prednisone in mexico purchase prednisone 10mg
http://amoxilall.com/# generic amoxicillin over the counter
prednisone generic cost: can i buy prednisone online without a prescription – prednisone online paypal
http://prednisoneall.com/# prednisone for sale
I was able to find good information from your articles.
https://pokhara.kr/bbs/board.php?bo_table=free&wr_id=379285