locked
How to get file upload progress from server RRS feed

  • Question

  • User264732274 posted

    just see the below code

    <form target="frame" 
          action="http://posttestserver.com/post.php?dir=example" 
          method="post"
          enctype="multipart/form-data">
        <input name="file" type="file"/>
    </form>
    
    <iframe name="frame"></iframe>
    
    $('input').change(function () {
        $('form').submit();
    });
    
    $.getJSON('/echo/jsonp/?callback=?', function(e, progress) {
        console.log(progress);
    });

    just do not understand when this getJSON will call ?

    $.getJSON('/echo/jsonp/?callback=?', function(e, progress) {
        console.log(progress);
    });

    what is relation between getJSON and $('input').change(function () {} code ?

    please help me to understand the code. code taken from http://stackoverflow.com/a/19432766/508127

    thanks

    Wednesday, February 3, 2016 11:38 AM

All replies

  • User61956409 posted

    Hi sudip_inn,

    Firstly, from the link you are referring, we could find that the reply is not marked as answer. Are you sure it is correct or helpful?

    Secondly,  if the change event of “input” fire, it will submit the form, then jQuery getJSON() method will be called to get JSON data using an AJAX request.

    $(function () {
        $('input').change(function () {
            $('form').submit();
        });
    
        $.getJSON('/echo/jsonp/?callback=?', function (e, progress) {
            console.log(progress);
        });
    })
    

    Best Regards,

    Fei Han

    Thursday, February 4, 2016 4:00 AM
  • User264732274 posted

    two set of jquery code not in same function. so i guess they are independent will also independently

    $('input').change(function () {
        $('form').submit();
    });
    
    $.getJSON('/echo/jsonp/?callback=?', function(e, progress) {
        console.log(progress);
    });

    when page run then getJSON() will be called........but getJSON should be run after form submit. what u say. thanks

    Thursday, February 4, 2016 8:23 AM