The function wp_localize_script()
is used to send variables to a script that has already been registered and enqueued. Do you have a js file that has been registered and enqueued and has the handle of ‘ajax_URL’? If not, then that explains why it isn’t working.
Also, ajaxurl is already a js variable that is accessible via any scripts you enqueue, so I’m not quite sure what you’re trying to do here.
If you’re just trying to add a new js file into your theme, you want to look at the wp_enqueue_script()
function.