Jquery .load function is not working as expected

<!DOCTYPE html>
<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>
            $(document).ready(function()
            {
                $("button").click(function()
                {
                    $("#div1").load("http://w3schools.com/jquery/demo_test.txt");
                });
            });
        </script>
    </head>
    <body>
        <div id="div1">
            <h2>Let jQuery AJAX Change This Text</h2>
        </div>
        <button>Get External Content</button>
    </body>
</html>

The preceding code is an example from W3Schools which I tried to run in my browser. While it works on W3schools window it refuses when I try to run it from my html page.

Upvotes: 0

Views: 98

Answers (1)

Brian
Brian

Reputation: 7654

Nope! You cannot use JavaScript to load a page from a remote website. This violates Same Domain Policy.

Upvotes: 3

Related Questions