是否可以在 XMLHttpRequest() 请求上添加 Jquery 移动加载程序?

Is it possible to add Jquery mobile loader on XMLHttpRequest() request?

  function uploadFile() {

    var fd = new FormData();

          var count = document.getElementById('image').files.length;

          for (var index = 0; index < count; index ++)

          {

                 var file = document.getElementById('image').files[index];

                 fd.append('myFile', file);

          }      
var xhr = new XMLHttpRequest();

        xhr.addEventListener("progress", updateProgress, false);
        xhr.addEventListener("load", uploadComplete, false);
        xhr.addEventListener("error", uploadFailed, false);
        xhr.open("POST", "savetofile.php", false);    

        xhr.send(fd);


 }
      function updateProgress(evt) {

        /* This event is raised when the server send back a response */
               $.mobile.showPageLoadingMsg();
      }

       function uploadComplete(evt) {

        /* This event is raised when the server send back a response */

          alert(evt.target.responseText);
          $.mobile.hidePageLoadingMsg()

      }

      function uploadFailed(evt) {

        alert("There was an error attempting to upload the file.");

      }

我正在使用 Jquert 移动框架,在此 XMLHttpRequest 中,我正在将文件上传到服务器,大约需要 5-6 秒才能 complete.I 阅读该文件以添加和删除页面加载(微调器)对于 jquery 移动版,只需添加 $.mobile.showPageLoadingMsg() [加载] 和 $.mobile.hidePageLoadingMsg()[删除]。我是否将功能放在了错误的位置?还是我犯了其他错误?

在解决方案中找到

function uploadFile() {

//ad this code 
$.mobile.loading('show', {
theme: "a",
text: "yoo",
textonly: true,
textVisible: true
});
//end
    var fd = new FormData();

          var count = document.getElementById('image').files.length;

          for (var index = 0; index < count; index ++)

          {

                 var file = document.getElementById('image').files[index];

                 fd.append('myFile', file);

          }