JavaScript why when i choose another file and submit, another request with the old file is sent? when do we choose another president

Hi i'm using Jquery Upload plugin. I've got this problem:

when i upload the first file this work fine,a single request is sent.

But if i select a second file and i upload it,two request are sent and not one how i expected, the first with the old file and the second with the new one. how i can avoid this behavior?

here's the code:

html:

<form id="upload"   >
Select video to upload:
<input id="fileupload" type="file" name="upl" data-url="php/fileUploader/uploaderVideoHandler.php" >
<input type="submit" value="Upload " name="submit">

javascript:

$(function () {
$('#fileupload').fileupload({
   method:'POST',
    acceptFileTypes: /(\.|\/)(mp4)$/i,
    dataType: 'json',
    maxNumberOfFiles: 1,
    replaceFileInput:false,
    autoUpload:false,
    add: function (e, data) {
        data.context = $('#upload').submit(

            function (e) {  
                            e.preventDefault();

                            data.submit();
            });
    },
    done: function (e, data) {
        data.file
        $('#progress .bar').text('Upload finished.');
    },
       progressall: function (e, data) {
    var progress = parseInt(data.loaded / data.total * 100, 10);
    $('#progress .bar').css(
        'width',
        progress + '%'
      );
    }
  });
 });

i try to reset data.files with

data.files.pop();

but doesn't work.

Solved: Instead using

 <input type="submit" value="Upload " name="submit">

i used a button

 <button id="up_btn">upload</button>

and i've changed add function to:

    $("#up_btn").off('click').on('click', function () {
        e.preventDefault();
        data.submit();
        return false;
    });
Answer:1

I've tried to render a simple component but cant seem to make it work. <Col md={{ span: 16, offset: 4 }} xs={{ span: 20, offset: 2 }}> {props.language === "en" ? <englishReport /> : &...

I've tried to render a simple component but cant seem to make it work. <Col md={{ span: 16, offset: 4 }} xs={{ span: 20, offset: 2 }}> {props.language === "en" ? <englishReport /> : &...

I have a scenario to get a output like the following. 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 When the input is 3 it would give 8 combinations as above. If the input is 4, there would be 16 ...

I have a scenario to get a output like the following. 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 When the input is 3 it would give 8 combinations as above. If the input is 4, there would be 16 ...

  1. recursive loop python
  2. recursive loop detected in template string
  3. recursive loop java
  4. recursive loop javascript
  5. recursive loop definition
  6. recursive loop c++
  7. recursive loop r
  8. recursive loop matlab
  9. recursive loop example
  10. recursive loop array javascript
  11. recursive loop in sql server
  12. recursive loop in oracle sql
  13. recursive loop php
  14. recursive loop knime
  15. recursive loop js
  16. recursive loop in angular 6
  17. recursive loop in jquery
  18. recursive loop in pl sql
  19. recursive loop start knime
  20. recursive loop through json

I'm using the Twitter Typeahead plugin: https://twitter.github.io/typeahead.js/ Here is the code I'm using: $(document).ready( function() { var bestPictures = new Bloodhound({ datumTokenizer:...

I'm using the Twitter Typeahead plugin: https://twitter.github.io/typeahead.js/ Here is the code I'm using: $(document).ready( function() { var bestPictures = new Bloodhound({ datumTokenizer:...

The code below will render a <h1> and two <button>. In my expectation, the changeString1 <button> will change letString to 1 and change <h1> text to 1 finally, while the ...

The code below will render a <h1> and two <button>. In my expectation, the changeString1 <button> will change letString to 1 and change <h1> text to 1 finally, while the ...