0

I have some problems using a loader from jquery mobile. I'm not a frontend developer, but I have to deal with this task. The aim is that I need to make it work the loader, keeping the submit. What it makes me mad is that in Chrome works and in Firefox not. The process of pick up a file and submit it works, it's only the loader what it fails. I've been reading several issues (but I'm not sure that it is right or not).

  1. Try to do the post from de javascript (ajax.post) but it doesn't work to send files.
  2. Try to preventDefault and then trigger again but I was not able to make it work and then also failed the submit process.
  3. remove the data-ajax=false but then it doesn't work the submit process.

In chrome works:

Loader in Chrome

But in Firefox not:

Loader in Firefox

I have a html file where is defined a submit form in order to send a file from the computer to a connected device. The html code is:

<form id="sw-update-form" name=multipart action="/upload" data-ajax="false" method="post" enctype="multipart/form-data">
  <fieldset data-role="controlgroup">
    <label id=ss1_l><input type="radio" name="update" value="fs1">Update filesystem 1</label>
    <label id=ss2_l><input type="radio" name="update" value="fs2">Update filesystem 2</label>
    <label for="file">Selected file:</label>
    <input type="file" name="file" id="file" />
    <input type="submit" name="upload" value="Update" />
  </fieldset>
</form>

And my js file with the code that deals with the jquery mobile loader is:

$(document).on( "pagecreate", "#page1", function() {
    $(document).on('submit', '#sw-update', function (e) {
        //e.preventDefault();
        var $this = $( this );
        $.mobile.loading( "show", {
                text: "Updating",
                textVisible: "true",
                theme: "b",
                textonly: "false",
                html : "<h1><img src=\"../images/ajax-loader.gif\"></h1><h1>Updating</h1>"
        });
    });
});

Since, it is not my area of expertise, can anyone help me? I think that it is necessary a loader because the process is long enough to required it.

Thanks for your help

UPDATE

If I click two times to the button summit, the loader works.

  • There isn't any spinner (JQM: $.mobile.loading) which will survive a page refresh. I suggest You to post the form along with the choosen files by using ajax, something like this: https://stackoverflow.com/a/23981045/4845566 – deblocker Apr 18 '21 at 07:11
  • Thanks for your suggestion, I'll check it. :) – ikki_fenix Apr 19 '21 at 07:04

0 Answers0