plugins_url() works everywhere but wp_reqister_script()

This is a PHP issue, not specific to WordPress. I suggest reading the PHP documentation on variable scope to understand why this doesn’t work.

There is no $plugin_url variable defined within the scope of your my_jquery_enqueue function, you would have to call global $plugin_url; first within the function to access it, though I don’t suggest using something as generic as $plugin_url.

Personally I would create a class for the plugin to encapsulate everything and not pollute the global scope.

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.