$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>admin-ajax.php mixed content|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

admin-ajax.php mixed content

matteradmin10PV0评论

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.

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.

Share Improve this question edited Mar 6, 2019 at 17:29 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Mar 6, 2019 at 17:19 Ivan KovalevIvan Kovalev 213 bronze badges 1
  • Problem resolved by moving my site to different hosting, dont know why, but it works fine on digitalocean. Forgot to mention, this problem was only when I used https, the whole site worked fine exept this one admin-ajax, on http admin-ajax worked fine. – Ivan Kovalev Commented Mar 7, 2019 at 18:03
Add a comment  | 

2 Answers 2

Reset to default 1

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',

for a default Wordpress installation,

url: 'https://'+window.location.host+'/admin/admin-ajax.php',

should be

    url: 'https://'+window.location.host+'/wp-admin/admin-ajax.php',

i.e /admin/ should be /wp-admin/.
I hope this helps.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far