0

I try to stop the refresh on my form when I use the change event.

JavaScript:

$(function() {

    $("input[type='file']").change(function () {
        console.log("on change ok");

        $("#modifier").submit(function (e) {

            console.log("on submit ok");
            /*
               treatment
            */
            e.preventDefault();
            return false;
        });
    });
} 

HTML:

<form action="" method="POST" enctype="multipart/form-data" id="modifier" >
    <input type="hidden" name="action" value="test" />
    <input type="file" name="upload" />
</form>

When picture is uploaded (input[type='file']), I'd like to submit it but I don't meed to refresh my page and do some treatment.

Alex Salauyou
  • 14,185
  • 5
  • 45
  • 67

0 Answers0