<script type="text/javascript" language="javascript">
var flag;	//it's a flag,when flag is true,the form can be submit;
	
$(function(){
	$('#warehouseCode').blur(function(){   
	    
	  var $warehouseCode=$("#warehouseCode").val();  
	  var url="ajaxRequest!isExistWarehouse.action";
	  var parm={warehouseCode:$warehouseCode};
	  $.post(url,parm,callbackFun,'json');   
	}) 
	function callbackFun(data){     
		 if(data.result=='false'){ 
		 	showDialog('提示','仓库编号已存在!','warning',2);
		 	flag=false;
		 }else{
		 	flag=true;
		 }
   	}
   	$('#save').click(function(){
 
		if($('#warehouseCode').val()==""){
			showDialog('Error','仓库编号不能为空','warning',2);
			flag=false;
		}else{
			flag=true;
		}
		if($('#warehouseName').val()==""){
			showDialog('Error','仓库编号不能为空','warning',2);
			flag=false;
		}else{
			flag=true;
		}
   		if(flag==false){
   			showDialog('提示','您还有一些输入不符合要求,请检查!','warning',2);
   			return false;
   		}else{
   			return true;
   		}
   	});
});	
</script>


<package name="ajax" extends="json-default">
        <action name="ajaxRequest">
            <result type="json"></result>
        </action>
    </package>


public class WareHouseAction extends BaseAction implements ModelDriven<Warehouses>{
	Warehouses warehouse=new Warehouses();
	 private String result;



	@Override
	public Warehouses getModel() {
		return warehouse;
	}
	public String isExistWarehouse(){
		String code=warehouse.getWarehouseCode().toString();
		if(code.equals("a")){
			result="false";
		}else{
			result="true";
		}
		return SUCCESS;
	}
	public String getResult() {
        return result;
    }

}


And finally, there is a Warehouses in javabean, not posted.

I am doing this demo encountered the following error

java.lang.NoSuchMethodError: com.opensymphony.xwork2.ActionContext.get (Ljava / lang / Object;) Ljava / lang / Object;
at com.googlecode.jsonplugin.JSONResult.execute (JSONResult.java: 156)

Json error because the wrong version of the plug-in package, struts2.1.x should use the 0.33 package, struts2.0.x of the package should be 0.32, we should pay attention to doing ah ~ ~!

Even in the annex these two packages are uploaded, we use it挑着