Forum Moderators: open
$('#photo-form').live('submit', function() {
$('#uploadingimage').show();
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: $(this).attr('method'), // GET or POST
enctype: $(this).attr('enctype'),
url: $(this).attr('action'), // the file to call
success: function(response) { // on success..
$('#uploadingimage').hide();
$('#upload_area').html(response);// update the DIV
}
});
return false; // cancel original event to prevent form submitting
});
$("#upload-button").click(function() {
var filename = $('form#filename').val();
var pieceID = $('form#pieceID').val();
var maxSize = $('form#maxSize').val();
var maxW = $('form#maxW').val();
var maxH = $('form#maxH').val();
var fullPath = $('form#fullPath').val();
var relPath = $('form#relPath').val();
var colorR = $('form#colorR').val();
var colorG = $('form#colorG').val();
var colorB = $('form#colorB').val();
var pic_name = $('form#pic_name').val();
var pic_description = $('form#pic_description').val();
var iframe = $( '<iframe name="postframe" id="postframe" class="hidden" src="about:none" />' );
$('div#iframe').append( iframe );
$('#photo-form').attr( "action", "upload.php" ),
$('#photo-form').attr( "method", "post" ),
$('#photo-form').attr( "filename", filename ),
$('#photo-form').attr( "pieceID", pieceID ),
$('#photo-form').attr( "maxH", maxH ),
$('#photo-form').attr( "maxW", maxW ),
$('#photo-form').attr( "fullPath", fullPath ),
$('#photo-form').attr( "relPath", relPath ),
$('#photo-form').attr( "colorR", colorR ),
$('#photo-form').attr( "colorG", colorG ),
$('#photo-form').attr( "colorB", colorB ),
$('#photo-form').attr( "pic_name", pic_name ),
$('#photo-form').attr( "pic_description", pic_description ),
$('#photo-form').attr( "enctype", "multipart/form-data" ),
$('#photo-form').attr( "encoding", "multipart/form-data" ),
$('#photo-form').attr( "target", "postframe" ),
$('#photo-form').submit();
//need to get contents of the iframe
$("#postframe").load(
function(){
iframeContents = $("iframe")[0].contentDocument.body.innerHTML;
$("div#upload_area").html(iframeContents);
}
);
return false;
});