JSFiddle - React, Tailwind, and code Playground

HTML

<form id="myform">
    <input type="submit" />
</form>

JavaScript

//wrap the form element in jQuery and cache it so we don't work to re-select it
var $myform = $('#myform');

//specify that we are listening for -when- the form is submit
$myform.on('submit', function(event){
    //prevents the form from actually submitting when submit is first clicked
    event.preventDefault();
    
    //Simpler image construction
    var image = new Image();
    document.body.appendChild(image);
    
    //remember to listen for the image's load event before assigning a source
    $(image).on('load', function(){
        //this function is invoked in the future,
        //when the image load event has been fired
        
        //normally, this bit would actually submit the form via GET or POST
        //$myform.submit();
        
        //but we're just testing for now
        alert('Image loaded!');
    });
    
    //an image's `src` attribute can be set directly via the`src` property
    image.src = "http://www.amorevasaturo.com/print/manhattan.jpg";
});