You shouldn’t do something like this in your JS code:
url: 'https://'+window.location.host+'/admin/admin-ajax.php',
You should use wp_localize_script
and pass proper URL in there.
Let’s say your AJAX call is located in file my-js-file.js
. Somewhere in your theme/plugin you have something like this
wp_enqueue_script( '<SOME_HANDLE>', ... . 'my-js-file.js' , ...);
You should add this after it:
wp_localize_script( '<SOME_HANDLE>', 'MyScriptData', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
And in your JS file it should be
$.ajax({
url: MyScriptData.ajax_url,
type:'post',