-1

I have this code:

        $(".input_photo").click(function() {

            $.post("ajax/imagefile.html", function(img){
                complete: $(".bp_load").fadeIn(0).html(img);
            });
        });

Imagefile is a simple HTML page that contains the form and input type file with ID imageform.

And I have another code:

            $('#photoimg').live('change', function(){
                $("#imageform").ajaxForm({
                    target: '.preview'
                }).submit();
            });

I searched in the web, and I understand that live is deprecated, and I have changed to on, but it doesn't work. The input type file is changed, but the event doesn't triggered.

yvonnezoe
  • 7,129
  • 8
  • 30
  • 47
user2465422
  • 157
  • 2
  • 9

1 Answers1

3

Equivalent to live using .on() is: {delegate syntax}

$(document).on('change', '#photoimg',function(){
                $("#imageform").ajaxForm({
                    target: '.preview'
                }).submit();
            });
A. Wolff
  • 74,033
  • 9
  • 94
  • 155