Php ajax发布等待消息

I have an html form to submit some information:

<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#form form').submit(function(){
            $.get('data.php', $(this).serialize(), function(data){
                $('#content').html(data);
            });             
            return false;
        });
    });
    </script>
</head>
<body>
<div id="form">
    <form>
         IP : <input type="text" name="urname"><br/>
        Port : <input type="text" name="urbirth"><br/>
        <input type="submit" name="submit" value="Submit">
    </form>
</div>
<div id="content">
</div>

Which uses this php:

<?php
error_reporting(0);
$name      = strtoupper($_REQUEST['urname']);
$birth     = strtoupper($_REQUEST['urbirth']);
$address   = "$name"; //Here you can specify the address you want to check ports
$port      = "80"; //Here you can specify the port you want to check from $address
$checkport = fsockopen($address, $port, $errnum, $errstr, 2); //The 2 is the time of ping in secs

//Here down you can put what to do when the port is closed
if (!$checkport) {
    echo "The port " . $port . " from " . $address . " seems to be closed."; //Only will echo that msg
} else {

    //And here, what you want to do when the port is open
    echo "The port " . $port . " from " . $address . " seems to be open."; //The msg echoed if port is open
}
?>

Since it takes a long time to get a reply from the server, I would like to show an "awaiting response" message while waiting for the ajax response. How would I do this?

you should show it before this line:

$.get('data.php', $(this).serialize(), function(data){

and hide after this:

$('#content').html(data);

Also you could use $.ajaxStart and $.ajaxStop to handle all AJAJ requests. Example

$(document).ajaxStart(function() {
   $( "#loading" ).show();
 });
$(document).ajaxStop(function() {
      $( "#loading" ).hide();
});

With such html

<div id="loading" style="display:none">waiting message<div>