Cant access admin-ajax from https. In my js i wrote
$.ajax({
url: 'https://'+window.location.host+'/admin/admin-ajax.php',
type:'post',
data:'action=bid_now_live_me&_pid='+ mypid ,
success: function (data) {
So I changed every url to https but still no luck. In chrome network I get
In console just lot’s of errors
Tried to force ssl by modifing my htaccess, wp-config and by using force ssl plugin. And of course I tried to disable all plugins.
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',