From within a javascript file in my rails application: I want to send a JSON request to my application, which returns an array of strings, and capture that return value within a variable.
From the root of the application: the path to the request is: '/employers/get_unique_employer_names.json'
So If I'm in development mode: the full url would be:
http://localhost:3000/employers/get_unique_employer_names.json
Something like this but it doesn't work:
// app/assets/javascripts/application.js
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require turbolinks
//= require_tree .
$(document).ready(function(){
var array_of_names = get: '/employers/get_unique_employer_names.json'
});