HttpManager.js 609 B

1234567891011121314151617181920
  1. let HttpManager = {
  2. httpPost(url, cb) {
  3. // var remoteUrl = AppConst.HTTPURL + "/config/popStarConfig.json";
  4. let xhr = new XMLHttpRequest();
  5. xhr.onreadystatechange = function () {
  6. if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
  7. let response = xhr.responseText;
  8. let obj = JSON.parse(response)
  9. cb && cb(1, obj);
  10. } else {
  11. cb && cb(-1, xhr.responseText);
  12. }
  13. };
  14. xhr.open("GET", url, true);
  15. xhr.send();
  16. }
  17. }
  18. module.exports = HttpManager;