jquery ajax实现异步验证以及java获取FTP文件列表

####html中的写法

<input type="text" id="app_name" name="appInfo.app_name" onblur="loadXMLDoc();" onfocus="delData();"/>
<div id="accDiv" style="color:#F00"></div>

####javascript中的写法

function loadXMLDoc() {
    if (document.getElementById("app_name").value == "") {
        document.getElementById("accDiv").innerHTML = "用户名不能为空";
        return;
    }
    var xmlHttp;
    if(window.XMLHttpRequest) { // code for IE7+
        xmlHttp = new XMLHttpRequest();
    }
    else { // code for IE5/IE6
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            if (xmlHttp.responseText == "false") {
                document.getElementById("accDiv").innerHTML = "文件名不可用,已存在!";
                isRightFilename = false;
            }
            else {
                document.getElementById("accDiv").innerHTML = "文件名可用";
                isRightFilename = true;
            }
        }
    }
    var a = document.getElementById("app_name").value;
    // get
    xmlHttp.open("GET", "***.action?appInfo.app_name=" + a + "&random=" + Math.random, true);
    xmlHttp.send();
}
function delData() {
    document.getElementById("app_name").value = "";
    document.getElementById("accDiv").innerHTML = "";
}

####action中的写法

public void validateVersionsInformation() throws IOException{

    try {
    if(appManager.exitFIleName(appInfo.getApp_name() + ".apk"))

            getResponse().getWriter().print("false");
    else 
        getResponse().getWriter().print("true");

} catch (Exception e) {
    e.printStackTrace();
}
}

####FTP工具类中的写法

//返回FTP目录下文件列表
public String[] getFileNameList() throws IOException 
{ 
   if(!connectToTheServer())
 return null;
   return ftpClient.listNames(); 

}