Basic ajax call in WordPress

You have to use the admin-ajax handler to do the AJAX call.

Replace file.php in var url = "file.php"; with

yoursite.com/wp-admin/admin-ajax.php?action=simple_ajax

And in your plugin / functions.php file, add

add_action('wp_ajax_nopriv_simple_ajax','process_simple_ajax'); //for non logged in user
add_action('wp_ajax_simple_ajax','process_simple_ajax'); //for nlogged in user

function process_simple_ajax(){
    $data = $_REQUEST; // retrieve your submitted data
    wp_send_json($data); // return the processed data to the browser as json
}