透過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」的訊息:

Cross doamin XML access

但如果套用上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>
Cross doamin XML access

可以看到已經可以抓到XML內容,這樣可以讓我們較為方便的去開發,其他詳細的使用說明可以參考Yahoo YQL Guide

You may also like...

43,384 Responses

  1. Stevepsymn表示:

    В чёрный список пирамид и лохотронов 31 августа 2022 года внесены следующие организации, обладающие признаками финансовой пирамиды или признаками мошенничества.
    большой анальный секс
    Etihad Rail (etihadrail-ae.com)

    Club Unite To Live, Life Is Good, Unite To Live (uniteto.live). Новый домен пирамиды находящегося в розыске Романа Василенко.

    TopBoom, «платформа хедж-фонда, специализирующегося на сделках с обратным исходом спортивного события» (topboom.vip, t.me/TopBoom001)

    Change Team, мошенники указывают реквизиты чужого юрлица ООО «АТТИС ГРУПП» (ОРГН 1207700314128, ИНН 9702022065), телеграм-канал «Change Team: Главный Канал» (change-team.ru). Фальшивый обменник раньше назывался C Exchange.
    Ещё лохотроны:
    Scam! Чёрный список пирамид и лохотронов и отзывы

    В чёрный список пирамид и лохотронов включены организации, имеющие признаки финансовой пирамиды по классификации Центрального банка; организации, обладающие признаками матричной пирамиды (массовый привод друзей, «столы»); сборы денег с пенсионеров и прочих незащищённых слоёв населения; хайпы; организации, имеющие негативные отзывы; структуры, оказывающие финансовые услуги без лицензии и прочие лохотроны за исключением псевдоброкеров, кооперативов (с ними тоже не рекомендуем связываться) и некоторых других категорий.

  2. Vincenthit表示:

    В чёрный список пирамид и лохотронов 31 августа 2022 года внесены следующие организации, обладающие признаками финансовой пирамиды или признаками мошенничества.
    жесткое групповое порно
    Etihad Rail (etihadrail-ae.com)

    Club Unite To Live, Life Is Good, Unite To Live (uniteto.live). Новый домен пирамиды находящегося в розыске Романа Василенко.

    TopBoom, «платформа хедж-фонда, специализирующегося на сделках с обратным исходом спортивного события» (topboom.vip, t.me/TopBoom001)

    Change Team, мошенники указывают реквизиты чужого юрлица ООО «АТТИС ГРУПП» (ОРГН 1207700314128, ИНН 9702022065), телеграм-канал «Change Team: Главный Канал» (change-team.ru). Фальшивый обменник раньше назывался C Exchange.
    Ещё лохотроны:
    Scam! Чёрный список пирамид и лохотронов и отзывы

    В чёрный список пирамид и лохотронов включены организации, имеющие признаки финансовой пирамиды по классификации Центрального банка; организации, обладающие признаками матричной пирамиды (массовый привод друзей, «столы»); сборы денег с пенсионеров и прочих незащищённых слоёв населения; хайпы; организации, имеющие негативные отзывы; структуры, оказывающие финансовые услуги без лицензии и прочие лохотроны за исключением псевдоброкеров, кооперативов (с ними тоже не рекомендуем связываться) и некоторых других категорий.

  3. Uxijpm表示:

    order ascorbic acid 500 mg without prescription – kaletra oral prochlorperazine pills

  4. Great site! I recommend to everyone!The best hotels

  5. Your article has broadened my understanding.월세 보증금 대출

  6. En guvenilir kumarhanede kazan?n Sweet bonanza

  7. Help you get the most out of the services – Promonode

  8. Seveceginiz bir online casino Sweet bonanza

  9. Kumar oynamak icin en iyi secim Sweet bonanza

  10. BryanVidge表示:

    Студия Подкастов в Москве, Запись подкастов в Москве.
    http://video-podcast.ru/

  11. En iyi kumarhanede sans?n?z? deneyin Sweet bonanza

  12. Great site! I recommend to everyone!online hotel booking

  13. Kumar oynamak icin mukemmel bir yer Sweet bonanza

  14. Wfmnmk表示:

    cost zofran – purchase oxybutynin pill ropinirole 2mg us

  15. Great site! I recommend to everyone!kms pico

  16. Adrianjug表示:

    KMSpico Download | Official KMS Website New July 2024
    toolkit
    Are you looking for the best tool to activate your Windows & Office? Then you should download and install KMSpico, as it is one of the best tools everyone should have. In this article, I will tell you everything about this fantastic tool, even though I will also tell you if this is safe to use.

    In this case, don’t forget to read this article until the end, so you don’t miss any critical information. This guide is for both beginners and experts as I came up with some of the rumours spreading throughout the internet.

    Perhaps before we move towards downloading or installing a section, we must first understand this tool. You should check out the guide below on this tool and how it works; if you already know about it, you can move to another section.
    What is KMSPico?
    KMPico is a tool that is used to activate or get a license for Microsft Windows as well as for MS Office. It was developed by one of the most famous developers named, Team Daz. However, it is entirely free to use. There is no need to purchase it or spend money downloading it. This works on the principle of Microsft’s feature named Key Management Server, a.k.a KMS (KMSPico named derived from it).

    The feature is used for vast companies with many machines in their place. In this way, it is hard to buy a Windows License for each device,, which is why KMS introduced. Now a company has to buy a KMS server for them and use it when they can get a license for all their machines.

    However, this tool also works on it, and similarly, it creates a server on your machine and makes it look like a part of that server. One thing different is that this tool only keeps the product activated for 180 days. This is why it keeps running on your machine, renews the license keys after 180 days, and makes it a permanent activation.

    KMSAuto Net
    Microsoft Toolkit
    Windows Loader
    Windows 10 Activator
    Features
    We already know what this tool means, so let’s talk about some of the features you are getting along with KMSPico. Reading this will surely help you understand whether you are downloading the correct file.

    Ok, so here are some of the features that KMSPico provides:

    Activate Windows & Office

    We have already talked about this earlier, as using this tool, you will get the installation key for both Microsoft Products. Whether it is Windows or Office, you can get a license in no time; however, this supports various versions.

    Supports Multi-Arch

    Since this supports both products, it doesn’t mean you have to download separate versions for each arch. One version is enough, and you can get the license for both x32-bit or even the x64-bit.

    It Is Free To Use

    Undoubtedly, everything developed by Team Daz costs nothing to us. Similarly, using this tool won’t cost you either, as it is entirely free. Other than this, it doesn’t come with any ads, so using it won’t be any trouble.

    Permanent License

    Due to the KMS server, this tool installs on our PC, we will get the license key for the rest of our lives. This is because the license automatically renews after a few days. To keep it permanent, you must connect your machine to the internet once 180 days.

    Virus Free

    Now comes the main feature of this tool that makes it famous among others. KMSPico is 100% pure and clean from such viruses or trojans. The Virus Total scans it before uploading to ensure it doesn’t harm our visitors.

  17. Kazanmak icin harika bir kumarhane Sweet bonanza

  18. Douglasslida表示:

    KMSpico: What is it?
    pico активатор
    Operating systems and Office suites are among the primary Microsoft software items that still need to be paid for. Some consumers may find alternate activation methods due to the perceived expensive cost of these items. There may be restrictions, unforeseen interruptions, and persistent activation prompts if these items are installed without being properly activated.

    Our KMSpico app was created as a solution to this issue. By using this program, customers may access all of the functionality of Microsoft products and simplify the activation procedure.
    KMSPico is a universal activator designed to optimize the process of generating and registering license codes for Windows and Office. Functionally, it is similar to key generators, but with the additional possibility of automatic integration of codes directly into the system. It is worth paying attention to the versatility of the tool, which distinguishes it from similar activators.
    The above discussion primarily focused on the core KMS activator, the Pico app. Understanding what the program is, we can briefly mention KMSAuto, a tool with a simpler interface.

    By using the KMSPico tool, you can setup Windows&Office for lifetime activation. This is an essential tool for anybody looking to reveal improved features and go beyond limitations. Although it is possible to buy a Windows or Office key.

    KMSPico 11 (last update 2024) allows you to activate Windows 11/10/8 (8.1)/7 and Office 2021/2019/2016/2013/2010 for FREE.

  19. Sizin icin en iyi online casino Sweet bonanza

  20. Great site! I recommend to everyone!kmspico download

  21. Lurgvw表示:

    purchase cyclobenzaprine without prescription – enalapril 10mg uk enalapril 5mg usa

  22. I?ve read several good stuff here. Certainly worth bookmarking for revisiting. I wonder how much effort you put to make such a excellent informative site.

  23. I like what you guys tend to be up too. Such clever work and exposure! Keep up the fantastic works guys I’ve you guys to my own blogroll.

  24. KmspicooBax表示:

    Great site! I recommend to everyone!kmspico

  25. En iyi kumarhanede oyun oynay?n Sweet bonanza

  26. En iyi kumarhaneyi tavsiye ederim Sweet bonanza

  27. H?zl? odeme yapan kumarhane Sweet bonanza

  28. I do not even know how I ended up here, but I thought this post was great. I do not know who you are but definitely you are going to a famous blogger if you aren’t already 😉 Cheers!

  29. En iyi kumarhanede buyuk kazan?n Sweet bonanza

  30. Herkesin tavsiye ettigi kumarhane Sweet bonanza

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。