My name is Edward Tanguay. I'm an American software and web developer living and working in Berlin, Germany.
JQUERY CODE EXAMPLE created on Sunday, May 02, 2010 permalink
How to load and display the contents of a text file with AJAX/Jquery
This example shows allows the user to click a button which loads and displays the contents of a text file (via proxy on the same domain).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script type="text/javascript"
        src="http://www.google.com/jsapi"></script>
        <script type="text/javascript">
            google.load("jquery", "1.4.2");
            google.setOnLoadCallback(function() {
                $('#loadButton').click(loadDataFromExernalWebsite);
            });
            function loadDataFromExernalWebsite() {
                var currentDomain = document.domain;
                $('#content').load('http://' + currentDomain + '/web/getdata/index.php?url=http://www.tanguay.info/knowsite/data.txt');
            }
        </script>
        <style type="text/css">
            .contentArea {
            background-color: #eee;
            padding: 10px;
            }        
        </style>
    </head>
<body>
    <p>Click the button to load content:</p>
    <input id="loadButton" type="button" value="load content"/>
    <pre id="content" class="contentArea">...</pre>
</body>
</html>
need markup?