PHP中有两个问题需要更改
不好:
wp_localize_script( \'customjquery\', \'ajaxurl\', admin_url( \'admin-
ajax.php\' ) );
更改为:
wp_localize_script( \'customjquery\', \'my_custom_vars\', [\'ajax_url\' => admin_url(\'admin-ajax.php\')] );
您的javascript需要进行这些更改
不好:
$.ajax({
type: \'POST\', // use $_POST method to submit data
dataType: "html",
url: ajaxurl,
更改为:
$.ajax({
type: \'POST\', // use $_POST method to submit data
dataType: "html",
url: my_custom_vars.ajax_url,