0

I have a ul with li of images. I am taking the last li and want to extract the image data from it to upload, other wise the server (Flask) tells me that the data is an HTMLLIElement.

So how do I got about this? Here's the JS code:

        // e.preventDefault(e);
        var img = new FormData();
        img.append('file',$("#preview_list li:last-child")[0]);

        // Debugging statement
        //$("#preview_list li:last-child").dialog();
        $.ajax({
            type : "POST",
            url : "/_process",
            data : img,
            contentType: false,
            dataType: false,
            cache: false,
            processData: false,
            success: function(data,textStatus,jqXHR) {
                alert(data['result']);
            }
        });
goelakash
  • 2,502
  • 4
  • 40
  • 56
  • I found this nifty technique here - http://stackoverflow.com/questions/10754661/javascript-getting-imagedata-without-canvas . But at the moment it only looks like a workaround. – goelakash Mar 02 '16 at 21:48