<script src='jquery.js'></script>
<script>
$(function(){
$("#starts").click(function(){
$.ajax({
type:'POST',
url:'ajax.test.php',
data:"username=2",
dataType:'text',
cache:false,
beforeSend: function(XMLHttpRequest){
$("#loading").show();
},
success:function(msg){
alert(msg);
},
complete: function(XMLHttpRequest, textStatus){
$("#loading").hide();
},
error:function(data){
if(data.status=="404"){
alert('请求地址出错!');
}
else if(data.status=="302"){
alert('连接网页出错');
} else if(data.status=="timeout"){
alert("请求超时!");
}else{
alert('请求未响应!请检查网络或VPN连接');
}
}
});
});
});
</script>
<span id="starts" style="cursor: pointer;">start</span>|||||||||||||
<span id="loading" style="display:none;">loading......</span>