Before I start I know this may be a duplicate. I have looked at the solution of the following:
jQuery .load() not working on my image
and changed my code. However I still can't get the load to fire. I've tried changing the .load
to .on('load' ...)
and basically butchered my code trying to get this working... I still can't get the alert()
to fire... Any ideas?
<html>
<head>
<title>XXX</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<div id="outter">
<div id="selectionBox">
<form id="qqqq" enctype="multipart/form-data" action="/" method="post">
<input id="fileSelect" onchange="readURL(this);" type="file" name="imagePP" accept="image/x-png, image/gif, image/jpeg, image/bmp">
</form>
</div>
</div>
</body>
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
if (!$("#aaa").length)
$("body").append("<img id=\"aaa\">");
$("#aaa").attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
$(document).ready(function() {
$("#aaa").load(function() {
alert("sdffds");
}).each(function() {
if (this.complete) {
$(this).trigger('load');
}
});
});
</script>
</html>