I can't load image with javascript. It runs until
alert('$img:'+$ (img));
and show alert but doesn't run the function about
$(img).load(fun ction () {
here is my javascript code.
From the about code starting from
$(img).load(fun ction () {
alert('img:'+im g);
......... to
$('#cropattrfor m').append(_cro p_bttn).append( _crop_cancel_bt tn);
}
}).attr('src', '/html/uploads/'+fileObj.name) ;
Does not work
Thanks and Regards,
Yan Paing
alert('$img:'+$ (img));
and show alert but doesn't run the function about
$(img).load(fun ction () {
here is my javascript code.
Code:
<script type="text/javascript">
$(function() {
$("#uploadify").uploadify({
'uploader' : 'uploadify/uploadify.swf',
'script' : '/html/crop/Uploader_files/index.jsp',
'cancelImg' : 'uploadify/cancel.png',
'folder' : 'photos',
'queueID' : 'fileQueue',
'auto' : true,
'buttonText' : 'upload',
'queueSizeLimit' : 1,
'multi' : true,
'fileDesc' : 'Support format: jpg / gif / jpeg / png / bmp.',
'fileExt' : '*. jpg; *. gif ; *. jpeg; *. png ',
'sizeLimit' : '99819200',//max size bytes - 800kb
'onComplete' : function (event, queueID, fileObj, response, data) {
alert("response:"+response.replace(/^\s+|\s+$/g,""));
alert("fileObj.name:"+fileObj.name);
//$('#uploadifyUploader').remove();
//var dataresponse = eval('(' + response + ')');
//alert("dataresponse:"+dataresponse);
//alert("dataresponse.result:"+dataresponse.result);
//dataresponse.result
if( 1==1){
var filenametmp ="";
//(fileObj.name).substring(0,(fileObj.name).lastIndexOf("?");
//$('#tempfile').val(filenametmp);
var img = new Image();
alert('img:'+img);
alert('$img:'+$(img));
$(img).load(function () {
alert('img:'+img);
$("#cropbox").remove();
alert('img:'+img);
$(".jcrop-holder").remove();
$(this).attr('id','cropbox');
$(this).hide();
$('#image_container').append(this);
$(this).fadeIn().Jcrop({
onChange: showPreview,
onSelect: showPreview,
aspectRatio: 1,
onSelect: updateCoords,
setSelect: [ 0, 0, 150, 150 ]
});
$("#preview").remove();
var _imgprev = $(document.createElement('img')).attr('id','preview').attr('src','/html/uploads/'+fileObj.name);
$('#preview_container').append(_imgprev);
alert('_crop_bttn:'+$('#_crop_bttn').length);
if(!$('#_crop_bttn').length){
var _crop_bttn = $(document.createElement('input')).attr('id','_crop_bttn').attr('type','submit').val('save');
var _crop_cancel_bttn = $(document.createElement('input')).attr('id','_crop_cancel_bttn').attr('type','submit').val('cancel');
_crop_cancel_bttn.click(function(){$('#cropattrform input.jq_step').val('cancel');});
_crop_bttn.click(function(){$('#cropattrform input.jq_step').val('process');});
$('#cropattrform').append(_crop_bttn).append(_crop_cancel_bttn);
}
}).attr('src', '/html/uploads/'+fileObj.name);
}
else
alert('error');
},
'onError' : function(event, queueID, fileObj, response, data){alert('error'+response);alert('error'+fileObj.name); }
});
});
$(img).load(fun ction () {
alert('img:'+im g);
......... to
$('#cropattrfor m').append(_cro p_bttn).append( _crop_cancel_bt tn);
}
}).attr('src', '/html/uploads/'+fileObj.name) ;
Does not work
Thanks and Regards,
Yan Paing
Comment