Utility.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. function RootPath() {
  2. var strFullPath = window.document.location.href;
  3. var strPath = window.document.location.pathname;
  4. var pos = strFullPath.indexOf(strPath);
  5. var prePath = strFullPath.substring(0, pos);
  6. var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
  7. //return (prePath + postPath);如果发布IIS,有虚假目录用用这句
  8. return (prePath);
  9. }
  10. function AjaxJson(url, postData, callBack) {
  11. $.ajax({
  12. url: RootPath() + url,
  13. type: "post",
  14. //contentType:"application/json",
  15. data: postData,
  16. dataType: "json",
  17. async: false,
  18. success: function (data) {
  19. if (data.Code == "-1") {
  20. //Loading(false);
  21. alertDialog(data.Message, -1);
  22. } else {
  23. //Loading(false);
  24. callBack(data);
  25. }
  26. },
  27. error: function (data) {
  28. //Loading(false);
  29. alertDialog(data.responseText, -1);
  30. }
  31. });
  32. }