How come jQuery.load() can work Cross-Domain if the URL has "just one HTML line"?

Viewed 8125

On my website, I'm attempting to code a JavaScript script that, upon a button being clicked, scrapes data from the HTML source of some websites and displays the parsed/cleaned data on my site.

Upon reading TutorialsPoint's JQuery - Ajax page, which showcases the jQuery.load() method,

<script type = "text/javascript" language = "javascript">
     $(document).ready(function() {
        $("#driver").click(function(event){
           $('#stage').load('/jquery/result.html');
        });
     });
</script>

I decided to try it on my site. I changed the URL from the relative one to the absolute one -- "http://www.tutorialspoint.com/jquery/result.html" -- and to my surprise, it is actually functioning (click EXTRACT DATA). This contradicts my understanding, upon reading dozens of SO threads, as well as the jQuery.load() API, that the HTTP request would be subject to the Same-Origin-Policy.

Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, port, or protocol. ~API

When I change the URL to things like http://google.com/ or http://www.example.com/ the script doesn't function.

A line on the aforereferenced tutorial page caught my eye:

Here load() initiates an Ajax request to the specified URL /jquery/result.html file. After loading this file, all the content would be populated inside tagged with ID stage. Assuming, our /jquery/result.html file has just one HTML line

How come load() works, across domains, if the HTML file at the specified URL has solely one line?

3 Answers
Related