function RootPath() { var strFullPath = window.document.location.href; var strPath = window.document.location.pathname; var pos = strFullPath.indexOf(strPath); var prePath = strFullPath.substring(0, pos); var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1); //return (prePath + postPath);如果发布IIS,有虚假目录用用这句 return (prePath); } function AjaxJson(url, postData, callBack) { $.ajax({ url: RootPath() + url, type: "post", //contentType:"application/json", data: postData, dataType: "json", async: false, success: function (data) { if (data.Code == "-1") { //Loading(false); dialogAlert(data.Message, -1); } else { //Loading(false); callBack(data); } }, error: function (data) { //Loading(false); dialogAlert(data.responseText, -1); } }); }