将XMLHttpRequest转换为jquery

将XMLHttpRequest转换为jquery,jquery,ajax,Jquery,Ajax,我有这个代码,我想在Jquery中转换 function GetServerTime() { var xmlhttp; if(window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("POST","ajax?type=GetSe

我有这个代码,我想在Jquery中转换

function GetServerTime() 
{
   var xmlhttp;
   if(window.XMLHttpRequest) {  
      xmlhttp=new XMLHttpRequest();  
   } else {  
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  
   }

   xmlhttp.open("POST","ajax?type=GetServerTime&rand=" + Math.random(),false);
   xmlhttp.send();
   return xmlhttp.responseText;
}
有人能帮忙吗???

使用


不能从异步函数返回,即使在jQuery中也不能
$.ajax({
  url: "ajax?type=GetServerTime&rand=" + Math.random(),
  type: "POST",
  async: false,
  success: function(result) {}
});
    $.ajax{
       url: "ajax?type=GetServerTime&rand=" + Math.random(),
       type: post,
       success: function(resp){
                 alert(resp);
                }
       }