Move the AJAX handler function hook outside of init callback and hook your script registrations to wp_enqueue_scripts. And, the hook to attach the handler callback would be wp_ajax_nopriv_postcode_ajax2. function ajax_postcode_form_init() { wp_register_script(‘ajax-login-script’, get_bloginfo(‘stylesheet_directory’). ‘/ajax-postcode-script.js’, array(‘jquery’) ); wp_localize_script( ‘ajax-login-script’, ‘ajax_login_object’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ), )); wp_enqueue_script(‘ajax-login-script’); } add_action(‘wp_enqueue_scripts’, ‘ajax_postcode_form_init’); function postcode_ajax2() { $postcode = … Read more