currently I can only do it in a normal non-wordpress way.
So, does wordpress provide a solution for this circumstance?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
ajaxurl. If this is for use on the front-end then you'll want to get the admin url:
<?php echo admin_url('admin-ajax.php'); ?>
//for logged in users only add_action('wp_ajax_MY_ACTION', 'my_ajax_function'); //for non-logged in users add_action('wp_ajax_nopriv_MY_ACTION', 'my_ajax_function');
MY_ACTION is the action sent with the AJAX request. You can hook the function that deals with the request, (in this example
my_ajax_function) onto the appropriate hook(s). This function should echo the response.
For more information see the above answers, and the Codex on Ajax in WordPress.