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">
<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.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>
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
  • 1
    Check http://stackoverflow.com/questions/727183/can-jquery-ajax-call-external-webservice – Ben Apr 28 '10 at 04:07

1 Answers1

2

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
  • 1,664
  • 1
  • 18
  • 26
  • 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 Apr 29 '10 at 03:56