What's wrong with this function:
function() {
$.get('/controller/action', function(data) {
$('#temporaryPhotos').text(data);
} );
return false;
}
What it should do is fetch HTML from /controller/action page and insert the HTML into the #temporaryPhotos div on the current page.
Initial markup looks like this:
<div id="temporaryPhotos"></div>
So it's just an empty div. The jQuery function should fill it with photos form another page (it's the same website, of course). But the div stays empty.
EDIT:
I think I have not been very clear with my post so here is an additional information. What I am actually trying to accomplish is to use the abovementioned function as a callback for the Uploadify jquery plugin (http://www.uploadify.com).
Here is the full javascript code:
$(document).ready(function() {
$('#photo').uploadify({
'uploader' : '/flash-uploader/scripts/uploadify.swf',
'script' : '/flash-uploader/scripts/upload-public-photo.php',
'cancelImg' : '/flash-uploader/cancel.png',
'scriptData' : {'user_id' : 'USER_ID'},
'queueID' : 'fileQueue',
'auto' : true,
'multi' : true,
'sizeLimit' : 2097152,
'fileExt' : '*.jpg;*.jpeg;*.gif;*.png',
'wmode' : 'transparent',
'onComplete' : function() {
$.get('/controller/action', function(data) {
alert(data);
$('#temporaryPhotos').html(data);
} );
return true;
}
});
});
I have tried both text() and html(), also alert(). Still nothing :(
EDIT2:
Upon further research I have found out that a default onComplete() function in the Uploadify plugin looks like this:
jQuery(this).bind("uploadifyComplete", {'action': settings.onComplete}, function(event, ID, fileObj, response, data) {
if (event.data.action(event, ID, fileObj, unescape(response), data) !== false) {
jQuery("#" + jQuery(this).attr('id') + ID + " .percentage").text(' - Completed');
jQuery("#" + jQuery(this).attr('id') + ID).fadeOut(250, function() { jQuery(this).remove()});
}
});
I have rewritten this function with my own (first one in this post) and that appears to be a problem.
EDIT3:
Head section of the page:
<script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/flash-uploader/scripts/swfobject.js"></script>
<script type="text/javascript" src="/flash-uploader/scripts/jquery.uploadify.v2.1.0.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$('#photo').uploadify({
'uploader' : '/flash-uploader/scripts/uploadify.swf',
'script' : '/flash-uploader/scripts/upload-public-photo.php',
'cancelImg' : '/flash-uploader/cancel.png',
'scriptData' : {'user_id' : 1},
'queueID' : 'fileQueue',
'auto' : true,
'multi' : true,
'sizeLimit' : 2097152,
'fileExt' : '*.jpg;*.jpeg;*.gif;*.png',
'wmode' : 'transparent',
'onComplete' : function() {
alert("hello");
}
});
}); //]]>
</script><script type="text/javascript" src="/js/document-ready.js"></script>