jQuery outside event plugin help needed?

jQuery outside event plugin help needed?

Hello, I am wanting to use the jQuery outside event plugin. Here is what I want to do....

I have a hyperlink on my html page, and when you click on it, it is suppose to use the GET function to get information from a php page into a DIV tag named "

display" in the html page. The DIV tag is hidden at first and is located on in a different part of the html page then where the hyperlink is, but when the hyperlink is clicked the DIV tag should be shown and get the data in it. Also I am wanting it if there is a click outside of the DIV tag named "display", the DIV tag named "display" is hidden. I know some how the GET function has to be wrapped in a click event, but I just don't know how to do it and do the rest, I just don't know how to do this, please help?

I hope i explained this right?


Here is some code I have so far:

MY HTML PAGE (main.html)
-----------------------------------------------------







$('# display ').hide();


$.get('messages/msg.php', function(data) {
     


$('#display').show();
      $('#display').html(data);
    });



<a href="#" id="link"> My Link</a>

<div id="display"></div>



-----------------------------------------------------------------------------------------------------------------------------------------------



MY PHP PAGE  (msg.php)
--------------------------------------------------

<?php

$result = mysql_query("SELECT * FROM messages  WHERE pm='0'  ")
or die(mysql_error()); 

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
    // Print out the contents of each row
    echo "<div class='pm".row['num']."

























'>";
    echo $row['message'];
    echo "</div>";
}

?>

-----------------------------------------------

Please help?
Thank You!