Use the plugin the way it was intended to be used.
$(document).ready(function () {
$(".uploadform").ajaxForm({
target: '#viewimage',
beforeSubmit: function () {
// this happens before the ajax request
$("#viewimage").html('Uploading...');
},
success: function () {
// this happens after the ajax request
$('img').imgAreaSelect({...}); // removed options for this sample, add them back in your code.
}
});
});
You don't need click events or submit events, or even to trigger the submit event, this all gets handled by the plugin. This piece of code replaces both code snippets in your question.