I am working on an app where the backend is written in RoR and the front end is written completely in javascript/jquery/ajax. My question is how can I pass a variable into a url for my ajax get request? My code:
$(document).ready(function() {
$("button").click(function() {
$.getJSON('http://www.mydomain.com/recipes/1', function(results) {
$('#1').val(results.recipe_name)
$('#2').val(results.author)
$('#3').val(results.level_of_difficulty)
$('#4').val(results.instructions)
$('#5').val(results.activity)
})
})
})
Right now, the URL is in the format /recipes/:id and I want the :id to be a variable so that the data will load correctly when I click "show" for different recipes... so something like http://www.mydomain/recipies/recipe_x
Thanks in advance!