您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

14 年前
14 年前
14 年前
14 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. //
  3. // MIT License (MIT)
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a
  6. // copy of this software and associated documentation files (the "Software"),
  7. // to deal in the Software without restriction, including without limitation
  8. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. // and/or sell copies of the Software, and to permit persons to whom the
  10. // Software is furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. //
  22. wn.xmlhttp = {
  23. request: function() {
  24. if ( window.XMLHttpRequest ) // Gecko
  25. return new XMLHttpRequest() ;
  26. else if ( window.ActiveXObject ) // IE
  27. return new ActiveXObject("MsXml2.XmlHttp") ;
  28. },
  29. complete: function(req, callback, url) {
  30. if (req.status==200 || req.status==304) {
  31. callback(req.responseText);
  32. } else {
  33. alert(url +' request error: ' + req.statusText + ' (' + req.status + ')' ) ;
  34. }
  35. },
  36. get: function(url, callback, args, async) {
  37. // async by default
  38. if(async === null) async=true;
  39. var req = wn.xmlhttp.request();
  40. // for async type
  41. req.onreadystatechange = function() {
  42. if (req.readyState==4) {
  43. wn.xmlhttp.complete(req, callback, url)
  44. }
  45. }
  46. // separator can be & or ?
  47. // based on if there are already arguments
  48. var sep = ((args && args.indexOf('?'))==-1) ? '?' : '&';
  49. // add arguments to url
  50. var u = args ? (url + sep + args) : url;
  51. // call the server
  52. req.open('GET', u, async);
  53. req.send(null);
  54. // for sync
  55. if(!async) {
  56. wn.xmlhttp.complete(req, callback, url)
  57. }
  58. }
  59. }