drupal_add_js not working I have this code in my javascript:

(function ($) {  
    Drupal.behaviors.myid_print_table_id_link = {
        attach: function (context, settings) { 
            $.ajax({
              type: 'POST', 
              url: '?q=myid_print/table_pager',                                      
              success: function(data) {
                console.log(data);                          
              }                                                 
            }).done(function(o) {                  
              console.log(o);                                
            });
        }
    }  
})(jQuery);


This calls a function called myid_print_table_pager declared in my hook menu:

 function myid_print_menu(){

     $items = array();
     $items['myid_print/table_pager'] = array(
         'title' =&gt; 'Table Pager',
         'page callback' =&gt; 'myid_print_table_pager',       
         'type' =&gt; MENU_CALLBACK,
     ); 
     return $items;
  }
 }


Below is my function:

function myid_print_table_pager(){
    drupal_add_js('$(document).ready(function () { alert("Hello!"); });', 'inline');
    watchdog('message', 'I've been here!');
}


I'm pretty sure that the function myid_print_table_pager is invoke because 'I've been here!' is seen in my watchdog table in my database. But why does the alert with the message Hello! has not been invoke?
I usually avoid calling drupal_add_js() and use the #attached property of the render array. The advantage of using #attached is that you don't need to implement additional hooks, the js is only added when needed, and (as I've been told) it works better with caching. Your code would look something like this:

function myid_print_menu() {
  $items = array();
  $items['myid_print/table_pager'] = array(
    'title' =&gt; 'Table Pager',
    'page callback' =&gt; 'myid_print_table_pager',
    'type' =&gt; MENU_CALLBACK,
  );
  return $items;
}


function myid_print_table_pager() {
  $build = array(
    '#markup' =&gt; 'Hello world!',
    '#attached' =&gt; array(
      'js' =&gt; array(
        array(
          'data' =&gt; '$(document).ready(function () { alert("Hello!"); });',
          'type' =&gt; 'inline',
        ),
      ),
    ),
  );
  return $build;
}


Disclaimer: untested code, please let me know if it doesn't work as expected.