//直接上代码了:

function isExist() {
var companyName = $("#company").val();
if(companyName==""){
  alert("'所属公司'不能为空!");
  $("#company").focus();
  return;
}
var num = 0;
$.ajax({
  url:"isExistCompany.do?company.companyName="+companyName+"&t="+new Date(),
  async: false,
  success:function(data) {
   num = data;
  }
});
if(num==0) {
  alert("您输入的公司不存在,请重新输入!");
  $("#company").val("")
  $("#company").focus();
  return false;
}
return true;
}


action中:public void isExistCompany() {
  try {
   int num = 0;
   String companyName = company.getCompanyName();
   if (company!=null|| StringUtil.notEmpty(companyName))
    num=companyService.getCompanyId(companyName);
   HttpServletResponse response = ServletActionContext.getResponse();
   response.setContentType("text/plain; charset=GBK");
   PrintWriter out = response.getWriter();
   out.print(num);
   out.flush();
  } catch (Exception e) {
   e.printStackTrace();
  }
}