views:

258

answers:

1

When the button in the following script gets clicked, it should load in the contents of the file "http://tanguay.info/knowsite/data.txt" and display it on the screen.

What is the correct syntaxt so that the .get() function retrieves the data from the external website and puts it in #content?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
        <script type="text/javascript"
        src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
        <script type="text/javascript">
            google.load("jquery", "1.3.2");
            google.setOnLoadCallback(function() {
                $('#loadButton').click(loadDataFromExernalWebsite);
            });
            function loadDataFromExernalWebsite() {
                $('#content').html('new content');
                //$.get("http://tanguay.info/knowsite/data.txt", function(data) { alert(data); }, );
            }
        </script>
    </head>
<body>
    <p>Click the button to load content:</p>
    <p id="content"></p>
    <input id="loadButton" type="button" value="load content"/>
</body>
</html>
+2  A: 

Have you thought of using jquery load

I put together a little code for a twitter app that loads a 2nd file with jquery load.

Hellonearthis
thanks, that looks like what I need, so I set up an example using .load() but it doesn't read in the file like it should, posted here: http://stackoverflow.com/questions/2734676/why-doesnt-jquery-load-load-a-text-file-from-an-external-website
Edward Tanguay