Q:

Why jquery option is not working when pass value using wp_localize_script?

I am developing a wordpress plugin and i am facing a problem when pass value to jquery using wp_localize_script . This is my code 
 function newsbox_load_custom_script() {

$newsbox_parameters = array(
'newsPerPage' => 4 ,
'newsTickerInterval' => 2500
);
wp_enqueue_script('newsbox-custom-script', plugins_url( '/scripts/custom.js', __FILE__ ),'', '1.0.1', true);
wp_localize_script('newsbox-custom-script', 'newsbox_parameters',$newsbox_parameters);

}
 add_action('wp_enqueue_scripts', 'newsbox_load_custom_script');

and this is jquery code
    jQuery(document).ready(function(){

      jQuery(".news_list").bootstrapNews({
         newsPerPage: newsbox_parameters.newsPerPage,
         autoplay: true,
         pauseOnHover: true,
         navigation: false,
         direction: 'down',
         newsTickerInterval: newsbox_parameters.newsTickerInterval,
         onToDo: function () {
            //console.log(this);
         }
      });
  });

If i write jquery like 
    jQuery(document).ready(function(){

      jQuery(".news_list").bootstrapNews({
         newsPerPage: 4,
         autoplay: true,
         pauseOnHover: true,
         navigation: false,
         direction: 'down',
         newsTickerInterval: 2500,
         onToDo: function () {
            //console.log(this);
         }
      });
  });

Then it work perfectly. http://digitalsensebd.com/newsbox/
But if i pass value using wp_localize_script, it is not working http://digitalsensebd.com/newsbox_plugin/?page_id=4
Please tell me the solution

A:

One difference I can see in the two examples is that in your working example you are using integer values for newsPerPage and newsTickerInterval.
wp_localize_script will create string values.  So in your custom.js script, try casting those to integers before using them.  As a test, try this:
jQuery(document).ready(function(){

    newsbox_parameters.newsPerPageInt = parseInt(newsbox_parameters.newsPerPage, 10);
    newsbox_parameters.newsTickerIntervalInt = parseInt(newsbox_parameters.newsTickerInterval, 10);

    jQuery(".news_list").bootstrapNews({
        newsPerPage: newsbox_parameters.newsPerPageInt,
        autoplay: true,
        pauseOnHover: true,
        navigation: false,
        direction: 'down',
        newsTickerInterval: newsbox_parameters.newsTickerIntervalInt,
        onToDo: function () {
            //console.log(this);
        }
    });
});

