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


  function uploadfile() {      var fd = new formdata();            var count = document.getelementbyid('image').files.length;            (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) {          /* event raised when server send response */                $.mobile.showpageloadingmsg();       }         function uploadcomplete(evt) {          /* event raised when server send response */            alert(evt.target.responsetext);           $.mobile.hidepageloadingmsg()        }        function uploadfailed(evt) {          alert("there error attempting upload file.");        } 

i using jquert mobile framework , in xmlhttprequest uploading file server , takes around 5-6 seconds complete.i have read add , remove page load(spinner) jquery mobile add $.mobile.showpageloadingmsg() [to load] , $.mobile.hidepageloadingmsg()[to remove]. have placed function in wrong positions? or did make other mistake ?

found on solution

function uploadfile() {  //ad code  $.mobile.loading('show', { theme: "a", text: "yoo", textonly: true, textvisible: true }); //end     var fd = new formdata();            var count = document.getelementbyid('image').files.length;            (var index = 0; index < count; index ++)            {                   var file = document.getelementbyid('image').files[index];                   fd.append('myfile', file);            }       

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -