Ajax InvokeCommand with custom Callback Primary tabs View(active tab)
In the JS side try with this:

(function($) {
  $.fn.uploadToS3 = function() {
    // Your code here.
  };
})(jQuery);


the PHP part looks ok to me.