imageUpdateCtrl.js 714 B

123456789101112131415161718192021
  1. // 自定义图片的更新方法例如: customImageUpdate("POST", "http://127.0.0.1:8000/luckysheetimageprocess/", d)
  2. function customImageUpdate(method, url, obj) {
  3. return new Promise((resolve, reject) => {
  4. const xhr = new XMLHttpRequest() || new ActiveXObject("Microsoft.XMLHTTP");
  5. xhr.open(method, url);
  6. xhr.send(JSON.stringify(obj)); // 发送 POST/GET 数据
  7. xhr.onreadystatechange = function () {
  8. if (xhr.readyState == 4) {
  9. if (xhr.status == 200) {
  10. resolve(xhr.responseText);
  11. } else {
  12. reject("error");
  13. }
  14. }
  15. };
  16. });
  17. }
  18. export {
  19. customImageUpdate
  20. }