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(function () {
here is my javascript 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); }
-
});
-
});
-
From the about code starting from
$(img).load(function () {
alert('img:'+img);
......... to
$('#cropattrform').append(_crop_bttn).append(_crop _cancel_bttn);
}
}).attr('src', '/html/uploads/'+fileObj.name);
Does not work
Thanks and Regards,
Yan Paing
2 4417
Whether its showing any script error on that line?
Thanks and Regards
Ramanan Kalirajan
Thanks for Reply Ramanankalirajan,
I didn't see any script error on that line when i run it.
I fixed the code and that error is fixed.But preview image alignment is now in problem.
Here is my code . - <link href="Uploader_files/default.css" rel="stylesheet" type="text/css">
-
<link href="Uploader_files/uploadify.css" rel="stylesheet"
-
type="text/css">
-
<link rel="stylesheet" href="Uploader_files/jquery.css" type="text/css">
-
<link rel="stylesheet" href="Uploader_files/demos.css" type="text/css">
-
<link rel="stylesheet" href="jcrop/jquery.Jcrop.css" type="text/css" />
-
-
-
<script type="text/javascript" language="javascript" src="Uploader_files/jquery-1.js"></script>
-
<script type="text/javascript" src="Uploader_files/swfobject.js"></script>
-
<script type="text/javascript" src="Uploader_files/jquery.js"></script>
-
<script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.0.min.js"></script>
-
<script type="text/javascript" src="jcrop/jquery.Jcrop.min.js"></script>
-
<script type="text/javascript" src="Uploader_files/jquery_002.js"></script>
-
-
-
<script type="text/javascript">
-
var imgName;
-
$(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) {
-
-
-
if( 1==1){
-
var filenametmp ="";
-
-
var img = new Image();
-
-
load(img,fileObj,this);
-
-
}
-
else
-
alert('error');
-
},
-
'onError' : function(event, queueID, fileObj, response, data){alert('error'+response);alert('error'+fileObj.name); }
-
});
-
});
-
function updateCoords(c)
-
{
-
-
$('#x').val(c.x);
-
$('#y').val(c.y);
-
$('#w').val(c.w);
-
$('#h').val(c.h);
-
-
};
-
function checkCoords()
-
{
-
-
if (parseInt($('#w').val())){
-
return true;
-
}
-
$('#x').val(0);
-
$('#y').val(0);
-
$('#w').val(150);
-
$('#h').val(150);
-
-
return true;
-
};
-
function showPreview(coords)
-
{
-
if (parseInt(coords.w) > 0)
-
{
-
var rx = 100 / coords.w;
-
var ry = 100 / coords.h;
-
-
$('#preview').css({
-
width: Math.round(rx * $imgpos.width) + 'px',
-
height: Math.round(ry * $imgpos.height) + 'px',
-
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
-
marginTop: '-' + Math.round(ry * coords.y) + 'px'
-
});
-
}
-
};
-
$imgpos = {
-
width : '100%',
-
height : '100%'
-
};
-
-
function load(img,fileObj,_this) {
-
-
var _imgContainer = $(document.createElement('img')).attr('src','/html/uploads/'+fileObj.name).attr('id','cropbox');
-
imgName=fileObj.name;
-
$(".jcrop-holder").remove();
-
$('#imgName').val(imgName);
-
$('#image_container').append(_imgContainer);
-
-
$('#cropbox').fadeIn().Jcrop({
-
-
onChange: showPreview,
-
onSelect: showPreview,
-
aspectRatio: 1,
-
onSelect: updateCoords,
-
setSelect: [ 0, 0, 100, 100 ]
-
});
-
-
$("#preview").remove();
-
-
var _imgprev = $(document.createElement('img')).attr('id','preview').attr('src','/html/uploads/'+fileObj.name).attr('name','tempImg');
-
$('#preview_container').append(_imgprev);
-
-
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(){
-
alert('_crop_cancel_bttn click : ');
-
$('#cropattrform input.jq_step').val('cancel');
-
});
-
_crop_bttn.click(function(){
-
-
$('#cropattrform input.jq_step').val('process');
-
});
-
$('#cropattrform').append(_crop_bttn).append(_crop_cancel_bttn);
-
}
-
-
}
-
</script>
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Aurel |
last post by:
Hi,
I'd like to crop an image into several others images considering the
following :
- no quality loss (I'd like to keep exactly the same quality).
- total images size must not be too high...
|
by: Kevin Smith |
last post by:
Is there a way to "auto-crop" an image in PIL? I have some PNG images
with white backgrounds that I want cropped to show only the non-white
portion in the center, but I don't see how I can do...
|
by: isaacyho |
last post by:
Is there a fast way to crop a vector? I have a vector of size n, and
want to reduce it to some subregion (x,y ). Seems like you shouldn't
have to recopy all of those elements into a new vector,...
|
by: Jazper |
last post by:
hi
how can i Insert, change and crop META-Tags auf a Webform
programmtechnically?
Regards
Jazper
|
by: ACaunter |
last post by:
Hi there,
I was wondering if there was a way to crop a peice of an ASP.Net Image,
allowing the user to zoom in on only a section of the picture??
any help would be appreciated!!
thanks
--...
|
by: John Salerno |
last post by:
I might be way off target even looking into this method for what I need
to do, but I'm still a little confused about the description of it:
crop
im.crop(box) => image
Returns a rectangular...
|
by: sampath nslabs |
last post by:
sir
How to crop the image in visual basic 6.0.iam geting in vb.net but i want purelly in vb.plese give the code for that or give me useful snippts.i expecting source code for crop the image .pls...
|
by: brahimbb17 |
last post by:
There is no foolproof way to always win when gambling
http://crop-finder-for-travian.blogspot.com . That is why it’s called
gambling, you take risks and reap the benefits when lady lucks sides
by...
|
by: Thekid |
last post by:
Hi, I have an image similar to a clock, with numbers and letters going around in a circle. I need to extract the numbers and letters from the image and have them print out in a straight line and in...
|
by: fuchsia555 |
last post by:
hi
is there a code to crop bottom border from an image when creating thumbnail for this image without crop the original image , but just crop 15px bottom border for creating the thumbnails for the...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |