How to load image from Custom Module with javascript?
drupal_get_path() is a PHP function so you cannot call it in your JS.

To use the result of that function in your JS you would need to call the function in your PHP and then add the output to the JS on the page. You can use Drupal.settings for this. For example:

// Settings to pass to our JS.
$settings = array(
  'loaderImgPath' =&gt; drupal_get_path(
    'module',
    'alx_infinite_scroll'
  ) + '/images/ajax-loader.gif',
);
// Add to the JS settings.
drupal_add_js(array('alx_infinite_scroll' =&gt; $settings), 'setting');


Then you can use something like this in your JS:

Drupal.behaviors.alxInfiniteScroll = {
  attach: function (context, settings) {
    var imgPath = settings.alx_infinite_scroll.loaderImgPath;
  }
}


I recommend reading some of the documentation on Drupal's JavaScript APIs as it goes over this. For example:  https://www.drupal.org/docs/7/api/javascript-api/managing-javascript-in-drupal-7

To do that though you need to add the above PHP code somewhere.
In your case you are loading your JS in the info file, which means it will load on every page.
I would advise against this unless you actually need your JS to run on all pages, but if you do want it on all pages you could use something like hook_page_build().

In that case since you are dealing with the page render array you can use the #attached method of adding JS and JS settings that is referred to on the documentation page I linked above.