我有一个 html 表单来提交一些信息:
<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>
哪个使用这个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
}
?>
由于从服务器获得回复需要很长时间,我想在等待 ajax 响应时显示“等待响应”消息。我该怎么做?