I have some code that displays a gallery of images. I have a call to a file that goes like this.
<script src="js/main.js"></script> Now one part of this file contains the code below. I would like to pass an argument into the file and then replace the tags element that is currently 'cars' with the given argument. I understand that i can do something like
<script src="js/main.js"> var tag = cat; </script> but i have no idea how to process that argument within the javascript.
Thank you very much! This is the section of the javascript file where i want to use the argument and do something like tags = 'argument'
// Load images via flickr for demonstration purposes: $.ajax({ url: 'http://api.flickr.com/services/rest/', data: { format: 'json', method: 'flickr.photos.search', api_key: 'XXXXXXXXXXXXXXXXXXX', tags: 'cars' }, dataType: 'jsonp', jsonp: 'jsoncallback' }).done(function (data) { var gallery = $('#gallery'), url; $.each(data.photos.photo, function (index, photo) { url = 'http://farm' + photo.farm + '.static.flickr.com/' + photo.server + '/' + photo.id + '_' + photo.secret; $('<a data-gallery="gallery"/>') .append($('<img>').prop('src', url + '_s.jpg')) .prop('href', url + '_b.jpg') .prop('title', photo.title) .appendTo(gallery); }); });