复制代码 代码如下: ?Js代码 <BR>////创建新目录 <BR> function newDir() { <BR> var txt = document.getElementById("newDirtxt"); <BR> var dirname = txt.value; <BR> if (dirname) { <BR> alert("请填写目录名"); <BR> } else { <BR> $.ajax({ <BR> type: "Post", <BR> url: "/center/directorynew", <BR> async: false, <BR> data: { dirname: dirname }, <BR> success: function(msg) { <BR> if (msg.length < 40) { <BR> var DirectoryID = document.getElementById("DirectoryID"); <BR> var tOption = document.createElement("Option"); <BR> tOption.text = dirname; <BR> tOption.value = msg; <BR> DirectoryID.appendChild(tOption); <BR> txt.value = ""; <BR> alert("增加成功"); <br><br> } else { <BR> alert("增加失败"); <BR> } <BR> } <BR> }); <BR> }//else <BR> } <BR> 后台代码 返回刚刚插入的目录的id字符串