To prevent wp_localize_script from localizing the AJAX URL in the array, simply exclude it from the array you pass to wp_localize_script. Here’s an example:
$data = array(
‘some_data’ => ‘value’,
// ‘ajax_url’ => admin_url(‘admin-ajax.php’), // Do not include this
);
wp_localize_script(‘your-script-handle’, ‘localizedData’, $data);
This way, the ajax_url is not included in the localized data.
-
This reply was modified 3 months, 1 week ago by altaan.