wp_enqueue_script() doesn’t work with AJAX

My problem is: I made an AJAX call using this code

wp_enqueue_script( 'prefix-myscript-name', plugins_url( 'js/ajaxcall.js', __FILE__ ) );

I made the call and the AJAX just going fine. I used this code:

Read More
add_action( 'wp_ajax_ajax_action', 'ajax_response' );
add_action( 'wp_ajax_nopriv_ajax_action', 'ajax_response' );

function ajax_response(){
    wp_enqueue_script( 'prefix-myscript-call', plugins_url( 'js/myscript.js', __FILE__ ) );
}

I used an alert('Test') in ajaxcall.js but it’s not showing up!

I’m disappointed. Any Solution?

Related posts