I keep getting this console error when trying to load data from an API
Uncaught ReferenceError: $ is not defined
I have tried placing a JQuery script within the app and it does not work.
I just want the data to append to the #resultContainer when the page is loaded
app/views/locations/show.html.erb
<div id="resultContainer"></div>
app/assets/javascripts/application.js
var _PremiumApiBaseURL = 'http://api.worldweatheronline.com/premium/v1/';
var _PremiumApiKey = 'APIKEY';
//Get Marine Weather Data
function JSONP_MarineWeather(input) {
var url = _PremiumApiBaseURL + "marine.ashx?q=" + input.query +
"&format=" + input.format +
"&fx=" + input.fx +
"&key=" + _PremiumApiKey +
"&tide=yes&";
jsonP(url, input.callback);
}
// Helper
function jsonP(url, callback) {
$.ajax({
type: 'GET',
url: url,
async: false,
contentType: "application/json",
jsonpCallback: callback,
dataType: 'jsonp',
success: function (json) {
console.dir('success');
},
error: function (e) {
console.log(e.message);
}
});
}
var resultContainer = $('#resultContainer');
var output = '';
$(document).ready(function () {
GetMarineWeather();
});
function GetMarineWeather(e) {
var marineWeatherInput = {
query: '26.13,-80.10',
format: 'JSON',
fx: '',
callback: 'MarineWeatherCallback'
};
JSONP_MarineWeather(marineWeatherInput);
e.preventDefault();
}
function MarineWeatherCallback(marineWeather) {
var allDataToday = marineWeather.data.weather[0]
output = "<br/> Date: " + allDataToday.date;
output += "<br/> Min Temp (f): " + allDataToday.mintempF;
output += " - Max Temp (f): " + allDataToday.maxtempF;
output += "<br/>";
//6AM
output += "<br/> Time: 6AM";
output += " - Surf: " + allDataToday.hourly[2].swellHeight_ft + "ft";
output += " - Swell: " + allDataToday.hourly[2].swellDir16Point + " " + allDataToday.hourly[2].swellPeriod_secs + "sec";
resultContainer.empty();
resultContainer.html(output);
}
Help