Using ajax with wordpress

In WordPress Ajax works this way:

First, you register the ajax action and the function you want to use to serve that action, of course, you have to write that function.

All the request go to the same URL wp-admin/admin-ajax.php, what it changes is the action, and depending on the action, a different function is called.

The function you call, returns the result, which you get as the response in the ajax request.

If you have any doubts of any step just ask.