Cannot pass variable to js file I cannot pass variable to js file, from my common.module

  $max_length = 10; //variable_get('title_max_length');
      drupal_add_js(drupal_get_path('theme', 'myTHEME'). '/js/script.js');
      drupal_add_js(array('common' =&gt; array('max' =&gt; $max_length)), array('type' =&gt; 'setting'));


Javascript works fine, but i need to get **$max_length** variable from module. At the moment its not working.
here is js file:

(function($, Drupal) {
/*Character limit for news node*/

    Drupal.behaviors.common = {
        attach: function(context, settings) {
            var length = $('#edit-title').val().length;
           /* ####################################### */
           /* Does not work */
            var char_limit = Drupal.settings.common.max; 
           /* ####################################### */
            if (length &gt;= char_limit) {
                $('div.form-item-title label span.form-required').text("characters left limit exceeded for displaying on home page");
            } else {
                $('div.form-item-title label span.form-required').text(char_limit-length-1 + " characters left");
            }

            $('#edit-title:not(.edit-title-processed)', context).keyup(function () {

                $(this).addClass('edit-title-processed');
                var new_length = $('#edit-title').val().length;

                if (new_length &gt;= char_limit) {
                    var chars = char_limit-new_length;
                    $('#edit-title').css('color','red');
                    //$('div.form-item-title label span.form-required').text("characters left limit exceeded for displaying on home page");
                    $('div.form-item-title label span.form-required').text("" + chars-1 + " characters");


                } else {
                    var chars = char_limit-new_length;
                    $('div.form-item-title label span.form-required').text(chars-1 + " characters left");
                    $('#edit-title').css('color', 'black');

                }
            });
        }
    };
})(jQuery, Drupal);
Interchange below lines that should work !!

$max_length = 10; //variable_get('title_max_length');
drupal_add_js(drupal_get_path('theme', 'myTHEME'). '/js/script.js');
drupal_add_js(array('common' =&gt; array('max' =&gt; $max_length)), array('type' =&gt; 'setting'));


to

$max_length = 10; //variable_get('title_max_length');
drupal_add_js(array('common' =&gt; array('max' =&gt; $max_length)), array('type' =&gt; 'setting'));
drupal_add_js(drupal_get_path('theme', 'myTHEME'). '/js/script.js');