function dropResource() {
var imgIndex = getImageIndexByID(currentDragImageID);
var newImgID = resourceData.length;
// Create the image
$('#thePage').append('<img alt="Big" id="imgA' + newImgID + '" src="' + uploadFolder + '/' + imgData[imgIndex][1] + '" class="mediaImg" />');
// Get properties
var imgW = $('#imgA' + newImgID).width();
var imgH = $('#imgA' + newImgID).height();
var imgX = $('#imgA' + newImgID).position().left;
var imgY = $('#imgA' + newImgID).position().top;
// Add to array (dbID, imgarrIndex, width, height, x, y)
resourceData[newImgID] = new Array(0, imgIndex, imgW, imgH, imgX, imgY);
//alert('artworkAjaxHandler.ashx?type=addResource&uploadID=' + currentDragImageID + '&page=' + currentPage + '&w=' + imgW + '&h=' + imgH + '&x=' + imgX + '&y=' + imgY);
// Save this as a resource
$.ajax({
url: 'artworkAjaxHandler.ashx?type=addResource&uploadID=' + currentDragImageID + '&page=' + currentPage + '&w=' + imgW + '&h=' + imgH + '&x=' + imgX + '&y=' + imgY,
This code adds an image to my drop area once the thumbnail has been dropped in. The problem is, the width and the height of the image are coming out as 0,0 because the ajax is called before the image has a chance to load... If I uncomment out the alert, and wait until the image loads fully then it works fine.
Is there anyway to get around this?