Created
June 18, 2015 20:03
-
-
Save bryantee/c99388d235f7100ffa4a to your computer and use it in GitHub Desktop.
ombdapi test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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