CORS localhost ajax request
You should wrap you javascript to user $ for jQuery, since it does not automatically refer to jQuery in Drupal 7. Try like that:

(function ($) {
  // Your code here
  $(document).ready(function() {
    // ...
  });
})(jQuery);


Reference: Managing JavaScript in Drupal 7