透過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。
amoxicillin 825 mg: buy amoxicillin 500mg capsules uk – amoxicillin 500 mg price
generic amoxicillin where to get amoxicillin over the counter amoxicillin 50 mg tablets
https://prednisonest.pro/# prednisone 50mg cost
where can you get amoxicillin: amoxicillin 500mg dosage – amoxicillin canada price
buy prednisone online fast shipping: prednisone cream over the counter – prednisone without prescription 10mg
prednisone drug costs prednisone cream prednisone 10mg tablet cost
https://clomidst.pro/# how to get generic clomid no prescription
amoxicillin without a prescription: amoxicillin 500mg how to take – amoxicillin 875 125 mg tab
where to buy clomid without dr prescription can you get generic clomid without insurance buying cheap clomid
http://amoxilst.pro/# amoxicillin 500mg
order clomid without dr prescription: how to get cheap clomid without insurance – clomid cheap
prednisone without prescription.net: does prednisone cause constipation – 40 mg daily prednisone
10mg prednisone daily: can you buy prednisone over the counter in canada – 80 mg prednisone daily
amoxicillin 500 mg: amoxicillin para que sirve – buy cheap amoxicillin online
where can i get amoxicillin 500 mg: can you drink alcohol amoxicillin 500mg dosage – cost of amoxicillin 875 mg
can you buy prednisone over the counter prednisone prescription online prednisone best prices
https://clomidst.pro/# clomid without a prescription
how to get amoxicillin over the counter: side effects of amoxicillin in adults – amoxicillin 500 mg without a prescription
prednisone tablets india: prednisone eye drops – generic prednisone pills
get cheap clomid online: order generic clomid online – generic clomid prices
can i get generic clomid: cost generic clomid for sale – can i get clomid price
https://amoxilst.pro/# amoxicillin price without insurance
can you buy generic clomid: clomid for testosterone – how can i get cheap clomid without dr prescription
amoxicillin online purchase: how much is amoxicillin without insurance – where can i get amoxicillin
http://clomidst.pro/# how to buy clomid for sale
medicine in mexico pharmacies Medicines Mexico buying prescription drugs in mexico online mexicanpharm.shop
http://mexicanpharm24.shop/# mexico drug stores pharmacies mexicanpharm.shop
Great site! I recommend everyone to view this siteGeek Bar
top 10 pharmacies in india: online pharmacy usa – reputable indian pharmacies indianpharm.store
https://indianpharm24.shop/# indian pharmacy online indianpharm.store