I working on adding file uploading to my web application. I'm using an iframe to post my upload. When my php script processes the upload it writes some JavaScript to the iframe. This JavaScript is attempting to attach a function to the parent, this works, but when this function actually gets called it doesn't have the correct scope. Here is the code I'm attaching to the parent window:
parent.window.showPreview = function(coords)
{
if (parseInt(coords.w) > 0)
{
var rx = 200 / coords.w;
var ry = 250 / coords.h;
$('#preview').css({
width: Math.round(rx * 400) + 'px',
height: Math.round(ry * 533) + 'px',
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
marginTop: '-' + Math.round(ry * coords.y) + 'px'
});
}
}
When this function gets executed I get an error that says $ is not defined. I've tried adding changing the JQuery call to parent.$('#preview').css..., but then it says that parent is undefined. Any ideas?