Yes, there is such way: you should pass absolute path in there…
Let’s say your JS file is enqueued like this:
wp_enqueue_script( 'my-script', 'path-to-js-file.js'... );
Then you should use wp_localize_script
and pass the value in there:
wp_localize_script( 'my-script', 'MyScriptData', array( 'ajax_url' => site_url('/test/file.html') ) );
Then you can access this value in your JS file this way:
return $.ajax({
type: 'get',
dataType: 'html',
url: MyScriptData.ajax_url, // <-- here you get that value...
success: function (resp) {
alert(‘Success’);
},
error: function (jqXHR) {
alert('Error ‘);
}
});
BUT…
You should know, that you SHOULD process AJAX requests using proper actions and not with some external file. Here you can read more about dealing with AJAX in WordPress: AJAX in Plugins