Skip to content

Instantly share code, notes, and snippets.

@bryantee
Created June 18, 2015 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryantee/c99388d235f7100ffa4a to your computer and use it in GitHub Desktop.
Save bryantee/c99388d235f7100ffa4a to your computer and use it in GitHub Desktop.
ombdapi test
$(function(){
$('#query').submit(function(event) {
event.preventDefault();
var searchTerm = $('#search-term').val();
var searchQuery = 'http://www.omdbapi.com/?s=' + searchTerm + 'r=json';
console.log('Using query :' + searchQuery);
$.getJSON(searchQuery, function(data) {
showResults(data.Search);
});
});
});
function showResults(results) {
var html = "";
for (index in results) {
html += '<p>' + results[index].Title + " : " + results[index].Year + '</p>';
console.log(results[index].Title + " : " + results[index].Year);
};
$('#search-results').html(html);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment