Login to download images will not click if called from AJAX Post

I have a hidden input:

<input class="hidden" id="imageInput" type="file" accept="image/*;capture=camera" />

The way this happens is a click that has a label that calls this function:

<label onclick="verifyValue(); return false;" class="hand-pointer">Click me!</label>

And my function verifyValue()looks like this:

function verifyValue() {
     app.ajax({
                type: "POST",
                dataType: 'json',
                url: myUrl + '/DoSomeVerification',
                contentType: 'application/json; charset=utf-8',
                cache: false,
                data: JSON.stringify(myData),
                success: function (result) {
                            //Success? Cool, stuff has been verified
                            //Let let them upload their image
                            $('#imageInput').click();
                   }
                error: { 
                            //Other stuff that not relevant
                   }
    });
}

My problem is that it $('#imageInput').click();does not work. When I debug this, it does it on this line and then does absolutely nothing. I have no errors, no dialog box to download the file or anything else.

To verify that this is not some other aspect of my code, I got rid of the AJAX post and simplified this function to the click event. When I get rid of the AJAX post, it works like a charm.

Also, if I do something like this instead .click():

$('#pickTicketImageUpload').removeClass('hidden');

Choose File .

, - , - , . - , ?

, , , , - , AJAX.

+4
1

async ajax - w3c .

, input = ajax done()

+3

Source: https://habr.com/ru/post/1665269/


All Articles