Specify ABSPATH in jQuery url

If your JavaScript is running in the admin, you don’t need to set an explicit path to admin-ajax.php. It’s always available as a JS variable called “ajaxurl”. You can see an example of this in the Codex, under the heading “AJAX on the Administration Side”

Ajaxurl is, unfortunately, not available on the frontend by default. But you can use a trcik with wp_localize_script() to declare it in a custom namespace, and use it in your frontend scripts. This is a really handy trick. More in this blog post (also linked from that Codex article).